use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableFloatObjectInspector in project hive by apache.
the class TestGenericUDFOPDivide method testFloatDivideFloat.
@Test
public void testFloatDivideFloat() throws HiveException {
GenericUDFOPDivide udf = new GenericUDFOPDivide();
FloatWritable f1 = new FloatWritable(4.5f);
FloatWritable f2 = new FloatWritable(1.5f);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableFloatObjectInspector, PrimitiveObjectInspectorFactory.writableFloatObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(f1), new DeferredJavaObject(f2) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(oi.getTypeInfo(), TypeInfoFactory.doubleTypeInfo);
DoubleWritable res = (DoubleWritable) udf.evaluate(args);
Assert.assertEquals(new Double(3.0), new Double(res.get()));
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableFloatObjectInspector in project hive by apache.
the class TestGenericUDFLevenshtein method testLevenshteinWrongType1.
public void testLevenshteinWrongType1() throws HiveException {
@SuppressWarnings("resource") GenericUDFLevenshtein udf = new GenericUDFLevenshtein();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableHiveVarcharObjectInspector;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
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 2nd argument, got FLOAT", e.getMessage());
}
}
Aggregations