Search in sources :

Example 1 with PrimitiveObjectInspectorFactory.javaShortObjectInspector

use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.javaShortObjectInspector in project hive by apache.

the class TestGenericUDFDateAdd method testShortDataTypeAsDays.

public void testShortDataTypeAsDays() throws HiveException {
    GenericUDFDateAdd udf = new GenericUDFDateAdd();
    ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
    ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.javaShortObjectInspector;
    ObjectInspector[] arguments = { valueOI1, valueOI2 };
    udf.initialize(arguments);
    DeferredObject valueObj1 = new DeferredJavaObject(new DateWritable(new Date(109, 06, 20)));
    DeferredObject valueObj2 = new DeferredJavaObject(new Short("4"));
    DeferredObject[] args = { valueObj1, valueObj2 };
    DateWritable output = (DateWritable) udf.evaluate(args);
    assertEquals("date_add() test for SHORT failed ", "2009-07-24", output.toString());
}
Also used : ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) DeferredJavaObject(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject) DateWritable(org.apache.hadoop.hive.serde2.io.DateWritable) DeferredObject(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject) GenericUDFDateAdd(org.apache.hadoop.hive.ql.udf.generic.GenericUDFDateAdd) Date(java.sql.Date)

Example 2 with PrimitiveObjectInspectorFactory.javaShortObjectInspector

use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.javaShortObjectInspector in project hive by apache.

the class TestGenericUDFDateSub method testShortDataTypeAsDays.

public void testShortDataTypeAsDays() throws HiveException {
    GenericUDFDateSub udf = new GenericUDFDateSub();
    ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
    ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.javaShortObjectInspector;
    ObjectInspector[] arguments = { valueOI1, valueOI2 };
    udf.initialize(arguments);
    DeferredObject valueObj1 = new DeferredJavaObject(new DateWritable(new Date(109, 06, 20)));
    DeferredObject valueObj2 = new DeferredJavaObject(new Short("4"));
    DeferredObject[] args = { valueObj1, valueObj2 };
    DateWritable output = (DateWritable) udf.evaluate(args);
    assertEquals("date_add() test for SHORT failed ", "2009-07-16", output.toString());
}
Also used : ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) DeferredJavaObject(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject) DateWritable(org.apache.hadoop.hive.serde2.io.DateWritable) GenericUDFDateSub(org.apache.hadoop.hive.ql.udf.generic.GenericUDFDateSub) DeferredObject(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject) Date(java.sql.Date)

Aggregations

Date (java.sql.Date)2 DeferredJavaObject (org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject)2 DeferredObject (org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject)2 DateWritable (org.apache.hadoop.hive.serde2.io.DateWritable)2 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)2 GenericUDFDateAdd (org.apache.hadoop.hive.ql.udf.generic.GenericUDFDateAdd)1 GenericUDFDateSub (org.apache.hadoop.hive.ql.udf.generic.GenericUDFDateSub)1