use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableIntObjectInspector in project hive by apache.
the class TestGenericUDFSoundex method testSoundexWrongType0.
public void testSoundexWrongType0() throws HiveException {
@SuppressWarnings("resource") GenericUDFSoundex udf = new GenericUDFSoundex();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
ObjectInspector[] arguments = { valueOI0 };
try {
udf.initialize(arguments);
assertTrue("soundex test. UDFArgumentTypeException is expected", false);
} catch (UDFArgumentTypeException e) {
assertEquals("soundex test", "soundex only takes STRING_GROUP types as 1st argument, got INT", e.getMessage());
}
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableIntObjectInspector in project hive by apache.
the class TestGenericUDFLevenshtein method testLevenshteinWrongType0.
public void testLevenshteinWrongType0() throws HiveException {
@SuppressWarnings("resource") GenericUDFLevenshtein udf = new GenericUDFLevenshtein();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector[] arguments = { valueOI0, valueOI1 };
try {
udf.initialize(arguments);
assertTrue("levenshtein test. UDFArgumentTypeException is expected", false);
} catch (UDFArgumentTypeException e) {
assertEquals("levenshtein test", "levenshtein only takes STRING_GROUP, VOID_GROUP types as 1st argument, got INT", e.getMessage());
}
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableIntObjectInspector in project hive by apache.
the class GenericUDFWidthBucket method initialize.
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
this.objectInspectors = arguments;
checkArgsSize(arguments, 4, 4);
checkArgPrimitive(arguments, 0);
checkArgPrimitive(arguments, 1);
checkArgPrimitive(arguments, 2);
checkArgPrimitive(arguments, 3);
PrimitiveObjectInspector.PrimitiveCategory[] inputTypes = new PrimitiveObjectInspector.PrimitiveCategory[4];
checkArgGroups(arguments, 0, inputTypes, NUMERIC_GROUP, VOID_GROUP);
checkArgGroups(arguments, 1, inputTypes, NUMERIC_GROUP, VOID_GROUP);
checkArgGroups(arguments, 2, inputTypes, NUMERIC_GROUP, VOID_GROUP);
checkArgGroups(arguments, 3, inputTypes, NUMERIC_GROUP, VOID_GROUP);
TypeInfo exprTypeInfo = TypeInfoUtils.getTypeInfoFromObjectInspector(this.objectInspectors[0]);
TypeInfo minValueTypeInfo = TypeInfoUtils.getTypeInfoFromObjectInspector(this.objectInspectors[1]);
TypeInfo maxValueTypeInfo = TypeInfoUtils.getTypeInfoFromObjectInspector(this.objectInspectors[2]);
TypeInfo commonExprMinMaxTypeInfo = FunctionRegistry.getCommonClassForComparison(exprTypeInfo, FunctionRegistry.getCommonClassForComparison(minValueTypeInfo, maxValueTypeInfo));
this.commonExprMinMaxOI = TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(commonExprMinMaxTypeInfo);
this.epxrConverterOI = ObjectInspectorConverters.getConverter(this.objectInspectors[0], this.commonExprMinMaxOI);
this.minValueConverterOI = ObjectInspectorConverters.getConverter(this.objectInspectors[1], this.commonExprMinMaxOI);
this.maxValueConverterOI = ObjectInspectorConverters.getConverter(this.objectInspectors[2], this.commonExprMinMaxOI);
return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
}
Aggregations