Search in sources :

Example 26 with TypeInfoFactory.booleanTypeInfo

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();
}
Also used : PrimitiveObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) DeferredJavaObject(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject) BooleanWritable(org.apache.hadoop.io.BooleanWritable) DeferredObject(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject) PrimitiveObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector) Test(org.junit.Test)

Example 27 with TypeInfoFactory.booleanTypeInfo

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();
}
Also used : PrimitiveObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) DeferredJavaObject(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject) BooleanWritable(org.apache.hadoop.io.BooleanWritable) DeferredObject(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject) BooleanWritable(org.apache.hadoop.io.BooleanWritable) Writable(org.apache.hadoop.io.Writable) PrimitiveObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector) Test(org.junit.Test)

Example 28 with TypeInfoFactory.booleanTypeInfo

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);
}
Also used : ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) BooleanWritable(org.apache.hadoop.io.BooleanWritable) Test(org.junit.Test)

Aggregations

ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)18 Test (org.junit.Test)17 BooleanWritable (org.apache.hadoop.io.BooleanWritable)16 DeferredJavaObject (org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject)12 DeferredObject (org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject)12 PrimitiveObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector)12 TypeInfo (org.apache.hadoop.hive.serde2.typeinfo.TypeInfo)11 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)9 ArrayList (java.util.ArrayList)8 ExprNodeConstantDesc (org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc)7 StructTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.StructTypeInfo)6 ExprNodeGenericFuncDesc (org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc)5 PrimitiveTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo)5 Writable (org.apache.hadoop.io.Writable)5 ExprNodeColumnDesc (org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc)4 CharTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.CharTypeInfo)4 DecimalTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo)4 VarcharTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeInfo)4 DataTypePhysicalVariation (org.apache.hadoop.hive.common.type.DataTypePhysicalVariation)3 VectorRandomBatchSource (org.apache.hadoop.hive.ql.exec.vector.VectorRandomBatchSource)3