use of org.apache.hadoop.hive.serde2.io.ByteWritable in project hive by apache.
the class TestGenericUDFAddMonths method runAndVerify.
private void runAndVerify(String str, byte months, String expResult, GenericUDF udf) throws HiveException {
DeferredObject valueObj0 = new DeferredJavaObject(new Text(str));
DeferredObject valueObj1 = new DeferredJavaObject(new ByteWritable(months));
DeferredObject[] args = { valueObj0, valueObj1 };
Text output = (Text) udf.evaluate(args);
assertEquals("add_months() test ", expResult, output != null ? output.toString() : null);
}
use of org.apache.hadoop.hive.serde2.io.ByteWritable in project hive by apache.
the class TestGenericUDFNullif method testByteTypeEq.
@Test
public void testByteTypeEq() throws HiveException {
GenericUDFNullif udf = new GenericUDFNullif();
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableByteObjectInspector, PrimitiveObjectInspectorFactory.writableByteObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(new ByteWritable((byte) 4)), new DeferredJavaObject(new ByteWritable((byte) 4)) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.byteTypeInfo, oi.getTypeInfo());
ByteWritable res = (ByteWritable) udf.evaluate(args);
Assert.assertEquals(null, res);
}
use of org.apache.hadoop.hive.serde2.io.ByteWritable in project hive by apache.
the class TestGenericUDFNullif method testConversionInSameGroup.
@Test
public void testConversionInSameGroup() throws HiveException {
GenericUDFNullif udf = new GenericUDFNullif();
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableDoubleObjectInspector, PrimitiveObjectInspectorFactory.writableByteObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(new DoubleWritable(4.0)), new DeferredJavaObject(new ByteWritable((byte) 4)) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
}
use of org.apache.hadoop.hive.serde2.io.ByteWritable in project hive by apache.
the class TestGenericUDFNullif method testConversionIsPrevented1.
@Test(expected = UDFArgumentException.class)
public void testConversionIsPrevented1() throws HiveException {
GenericUDFNullif udf = new GenericUDFNullif();
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableStringObjectInspector, PrimitiveObjectInspectorFactory.writableByteObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(new Text("4")), new DeferredJavaObject(new ByteWritable((byte) 4)) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
}
use of org.apache.hadoop.hive.serde2.io.ByteWritable 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);
}
Aggregations