use of org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject in project hive by apache.
the class TestGenericUDFNextDay method runAndVerify.
private void runAndVerify(String date, String dayOfWeek, String expResult, GenericUDF udf) throws HiveException {
DeferredObject valueObj0 = new DeferredJavaObject(date != null ? new Text(date) : null);
DeferredObject valueObj1 = new DeferredJavaObject(dayOfWeek != null ? new Text(dayOfWeek) : null);
DeferredObject[] args = { valueObj0, valueObj1 };
Text output = (Text) udf.evaluate(args);
assertEquals("next_day() test ", expResult, output != null ? output.toString() : null);
}
use of org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject in project hive by apache.
the class TestGenericUDFNullif method testNotSupportedArgumentMix.
@Test(expected = UDFArgumentException.class)
public void testNotSupportedArgumentMix() throws HiveException {
GenericUDFNullif udf = new GenericUDFNullif();
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableDateObjectInspector, PrimitiveObjectInspectorFactory.writableByteObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(new DateWritable(4)), new DeferredJavaObject(new ByteWritable((byte) 4)) };
udf.initialize(inputOIs);
}
use of org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject 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.ql.udf.generic.GenericUDF.DeferredObject 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.ql.udf.generic.GenericUDF.DeferredObject in project hive by apache.
the class TestGenericUDFNullif method testDateCompareEq.
@Test
public void testDateCompareEq() throws HiveException {
GenericUDFNullif udf = new GenericUDFNullif();
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableDateObjectInspector, PrimitiveObjectInspectorFactory.writableDateObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(new DateWritable(4)), new DeferredJavaObject(new DateWritable(4)) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.dateTypeInfo, oi.getTypeInfo());
Assert.assertEquals(null, udf.evaluate(args));
}
Aggregations