use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableByteObjectInspector in project hive by apache.
the class TestGenericUDFNullif method testConversionIsPrevented2.
@Test(expected = UDFArgumentException.class)
public void testConversionIsPrevented2() throws HiveException {
GenericUDFNullif udf = new GenericUDFNullif();
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableByteObjectInspector, PrimitiveObjectInspectorFactory.writableStringObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(new ByteWritable((byte) 4)), new DeferredJavaObject(new Text("4")) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableByteObjectInspector 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.primitive.PrimitiveObjectInspectorFactory.writableByteObjectInspector 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.primitive.PrimitiveObjectInspectorFactory.writableByteObjectInspector in project hive by apache.
the class TestGenericUDFOPPositive method testByte.
@Test
public void testByte() throws HiveException {
GenericUDFOPPositive udf = new GenericUDFOPPositive();
ByteWritable input = new ByteWritable((byte) 4);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableByteObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(input) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.byteTypeInfo, oi.getTypeInfo());
ByteWritable res = (ByteWritable) udf.evaluate(args);
Assert.assertEquals((byte) 4, res.get());
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableByteObjectInspector in project hive by apache.
the class TestGenericUDFPosMod method testPosModByZero1.
@Test
public void testPosModByZero1() throws HiveException {
GenericUDFPosMod udf = new GenericUDFPosMod();
// Byte
ByteWritable b1 = new ByteWritable((byte) 4);
ByteWritable b2 = new ByteWritable((byte) 0);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableByteObjectInspector, PrimitiveObjectInspectorFactory.writableByteObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(b1), new DeferredJavaObject(b2) };
udf.initialize(inputOIs);
ByteWritable b3 = (ByteWritable) udf.evaluate(args);
Assert.assertNull(b3);
}
Aggregations