use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.shortTypeInfo in project hive by apache.
the class TestGenericUDFOPNegative method testShort.
@Test
public void testShort() throws HiveException {
GenericUDFOPNegative udf = new GenericUDFOPNegative();
ShortWritable input = new ShortWritable((short) 74);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableShortObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(input) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.shortTypeInfo, oi.getTypeInfo());
ShortWritable res = (ShortWritable) udf.evaluate(args);
Assert.assertEquals((short) -74, res.get());
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.shortTypeInfo in project hive by apache.
the class TestGenericUDFOPMinus method testByteMinusShort.
@Test
public void testByteMinusShort() throws HiveException {
GenericUDFOPMinus udf = new GenericUDFOPMinus();
ByteWritable left = new ByteWritable((byte) 4);
ShortWritable right = new ShortWritable((short) 6);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableByteObjectInspector, PrimitiveObjectInspectorFactory.writableShortObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(left), new DeferredJavaObject(right) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(oi.getTypeInfo(), TypeInfoFactory.shortTypeInfo);
ShortWritable res = (ShortWritable) udf.evaluate(args);
Assert.assertEquals(-2, res.get());
}
Aggregations