use of org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector in project hive by apache.
the class TestGenericUDFCeil method testByte.
@Test
public void testByte() throws HiveException {
GenericUDFCeil udf = new GenericUDFCeil();
ByteWritable input = new ByteWritable((byte) 4);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableByteObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(input) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.longTypeInfo, oi.getTypeInfo());
LongWritable res = (LongWritable) udf.evaluate(args);
Assert.assertEquals(4L, res.get());
}
use of org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector in project hive by apache.
the class TestGenericUDFFloor method testDouble.
@Test
public void testDouble() throws HiveException {
GenericUDFFloor udf = new GenericUDFFloor();
DoubleWritable input = new DoubleWritable(32300.004747);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableDoubleObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(input) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.longTypeInfo, oi.getTypeInfo());
LongWritable res = (LongWritable) udf.evaluate(args);
Assert.assertEquals(32300L, res.get());
}
use of org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector in project hive by apache.
the class TestGenericUDFFloor method testDecimal.
@Test
public void testDecimal() throws HiveException {
GenericUDFFloor udf = new GenericUDFFloor();
HiveDecimalWritable input = new HiveDecimalWritable(HiveDecimal.create("32300.004747"));
DecimalTypeInfo inputTypeInfo = TypeInfoFactory.getDecimalTypeInfo(11, 6);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(inputTypeInfo) };
DeferredObject[] args = { new DeferredJavaObject(input) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.getDecimalTypeInfo(6, 0), oi.getTypeInfo());
HiveDecimalWritable res = (HiveDecimalWritable) udf.evaluate(args);
Assert.assertEquals(HiveDecimal.create("32300"), res.getHiveDecimal());
}
use of org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector in project hive by apache.
the class TestGenericUDFFloor method testByte.
@Test
public void testByte() throws HiveException {
GenericUDFFloor udf = new GenericUDFFloor();
ByteWritable input = new ByteWritable((byte) 4);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableByteObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(input) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.longTypeInfo, oi.getTypeInfo());
LongWritable res = (LongWritable) udf.evaluate(args);
Assert.assertEquals(4L, res.get());
}
use of org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector in project hive by apache.
the class TestGenericUDFFloor method testLong.
@Test
public void testLong() throws HiveException {
GenericUDFFloor udf = new GenericUDFFloor();
LongWritable input = new LongWritable(3234747);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableLongObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(input) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.longTypeInfo, oi.getTypeInfo());
LongWritable res = (LongWritable) udf.evaluate(args);
Assert.assertEquals(3234747L, res.get());
}
Aggregations