use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.booleanTypeInfo in project hive by apache.
the class TestGenericUDFOPAnd method testTrueAndTrue.
@Test
public void testTrueAndTrue() throws HiveException, IOException {
GenericUDFOPAnd udf = new GenericUDFOPAnd();
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 TestGenericUDFOPAnd method testTrueAndFalse.
@Test
public void testTrueAndFalse() throws HiveException, IOException {
GenericUDFOPAnd udf = new GenericUDFOPAnd();
BooleanWritable left = new BooleanWritable(true);
BooleanWritable right = new BooleanWritable(false);
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(false, res.get());
udf.close();
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.booleanTypeInfo in project hive by apache.
the class TestGenericUDFOPOr method testTrueOrFalse.
@Test
public void testTrueOrFalse() throws HiveException, IOException {
GenericUDFOPOr udf = new GenericUDFOPOr();
BooleanWritable left = new BooleanWritable(true);
BooleanWritable right = new BooleanWritable(false);
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 testFalseOrNull.
@Test
public void testFalseOrNull() throws HiveException, IOException {
GenericUDFOPOr udf = new GenericUDFOPOr();
BooleanWritable left = new BooleanWritable(false);
Writable right = null;
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableBooleanObjectInspector, 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 TestGenericUDFOPOr method testTrueOrNull.
@Test
public void testTrueOrNull() throws HiveException, IOException {
GenericUDFOPOr udf = new GenericUDFOPOr();
BooleanWritable left = new BooleanWritable(true);
Writable right = null;
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableBooleanObjectInspector, 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(true, res.get());
udf.close();
}
Aggregations