Search in sources :

Example 1 with SettableHiveDecimalObjectInspector

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

the class GenericUDFToDecimal method initialize.

@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    if (arguments.length < 1) {
        throw new UDFArgumentLengthException("The function DECIMAL requires at least one argument, got " + arguments.length);
    }
    try {
        argumentOI = (PrimitiveObjectInspector) arguments[0];
    } catch (ClassCastException e) {
        throw new UDFArgumentException("The function DECIMAL takes only primitive types");
    }
    // Check if this UDF has been provided with type params for the output varchar type
    SettableHiveDecimalObjectInspector outputOI;
    outputOI = (SettableHiveDecimalObjectInspector) PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(typeInfo);
    bdConverter = new HiveDecimalConverter(argumentOI, outputOI);
    return outputOI;
}
Also used : UDFArgumentException(org.apache.hadoop.hive.ql.exec.UDFArgumentException) HiveDecimalConverter(org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorConverter.HiveDecimalConverter) UDFArgumentLengthException(org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException) SettableHiveDecimalObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableHiveDecimalObjectInspector)

Aggregations

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