Search in sources :

Example 1 with SettableTimestampLocalTZObjectInspector

use of org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableTimestampLocalTZObjectInspector in project hive by apache.

the class GenericUDFToTimestampLocalTZ method initialize.

@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    if (arguments.length < 1) {
        throw new UDFArgumentLengthException("The function CAST as TIMESTAMP WITH LOCAL TIME ZONE requires at least one argument, got " + arguments.length);
    }
    try {
        argumentOI = (PrimitiveObjectInspector) arguments[0];
        switch(argumentOI.getPrimitiveCategory()) {
            case CHAR:
            case VARCHAR:
            case STRING:
            case DATE:
            case TIMESTAMP:
            case TIMESTAMPLOCALTZ:
                break;
            default:
                throw new UDFArgumentException("CAST as TIMESTAMP WITH LOCAL TIME ZONE only allows" + "string/date/timestamp/timestamp with time zone types");
        }
    } catch (ClassCastException e) {
        throw new UDFArgumentException("The function CAST as TIMESTAMP WITH LOCAL TIME ZONE takes only primitive types");
    }
    SettableTimestampLocalTZObjectInspector outputOI = (SettableTimestampLocalTZObjectInspector) PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(typeInfo);
    converter = new TimestampLocalTZConverter(argumentOI, outputOI);
    return outputOI;
}
Also used : UDFArgumentException(org.apache.hadoop.hive.ql.exec.UDFArgumentException) SettableTimestampLocalTZObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableTimestampLocalTZObjectInspector) UDFArgumentLengthException(org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException) TimestampLocalTZConverter(org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorConverter.TimestampLocalTZConverter)

Aggregations

UDFArgumentException (org.apache.hadoop.hive.ql.exec.UDFArgumentException)1 UDFArgumentLengthException (org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException)1 TimestampLocalTZConverter (org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorConverter.TimestampLocalTZConverter)1 SettableTimestampLocalTZObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableTimestampLocalTZObjectInspector)1