use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.booleanTypeInfo in project hive by apache.
the class TestGenericUDFOPOr method testTrueOrTrue.
@Test
public void testTrueOrTrue() throws HiveException, IOException {
GenericUDFOPOr udf = new GenericUDFOPOr();
BooleanWritable left = new BooleanWritable(true);
BooleanWritable right = new BooleanWritable(true);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableBooleanObjectInspector, PrimitiveObjectInspectorFactory.writableBooleanObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(left), new DeferredJavaObject(right) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(oi.getTypeInfo(), TypeInfoFactory.booleanTypeInfo);
BooleanWritable res = (BooleanWritable) udf.evaluate(args);
Assert.assertEquals(true, res.get());
udf.close();
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.booleanTypeInfo in project hive by apache.
the class TestGenericUDFOPOr method testNullOrNull.
@Test
public void testNullOrNull() throws HiveException, IOException {
GenericUDFOPOr udf = new GenericUDFOPOr();
Writable left = null;
Writable right = null;
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableVoidObjectInspector, PrimitiveObjectInspectorFactory.writableVoidObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(left), new DeferredJavaObject(right) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(oi.getTypeInfo(), TypeInfoFactory.booleanTypeInfo);
BooleanWritable res = (BooleanWritable) udf.evaluate(args);
Assert.assertEquals(null, res);
udf.close();
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.booleanTypeInfo in project hive by apache.
the class TestGenericUDFMonthsBetween method testMonthsBetweenForDate.
@Test
public void testMonthsBetweenForDate() throws HiveException {
GenericUDFMonthsBetween udf = new GenericUDFMonthsBetween();
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
ObjectInspector[] arguments = { valueOI1, valueOI2 };
udf.initialize(arguments);
testMonthsBetweenForDate(udf);
// Run without round-off
GenericUDFMonthsBetween udfWithoutRoundOff = new GenericUDFMonthsBetween();
ObjectInspector vOI1 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
ObjectInspector vOI2 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
ObjectInspector vOI3 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.booleanTypeInfo, new BooleanWritable(false));
ObjectInspector[] args = { vOI1, vOI2, vOI3 };
udfWithoutRoundOff.initialize(args);
testMonthsBetweenForDate(udfWithoutRoundOff);
}
Aggregations