Search in sources :

Example 1 with HiveCharConverter

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

the class GenericUDFToChar method initialize.

@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    if (arguments.length != 1) {
        throw new UDFArgumentException("CHAR cast requires a value argument");
    }
    try {
        argumentOI = (PrimitiveObjectInspector) arguments[0];
    } catch (ClassCastException e) {
        throw new UDFArgumentException("The function CHAR takes only primitive types");
    }
    // Check if this UDF has been provided with type params for the output char type
    SettableHiveCharObjectInspector outputOI;
    outputOI = (SettableHiveCharObjectInspector) PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(typeInfo);
    converter = new HiveCharConverter(argumentOI, outputOI);
    return outputOI;
}
Also used : UDFArgumentException(org.apache.hadoop.hive.ql.exec.UDFArgumentException) HiveCharConverter(org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorConverter.HiveCharConverter) SettableHiveCharObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableHiveCharObjectInspector)

Aggregations

UDFArgumentException (org.apache.hadoop.hive.ql.exec.UDFArgumentException)1 HiveCharConverter (org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorConverter.HiveCharConverter)1 SettableHiveCharObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableHiveCharObjectInspector)1