use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFLikeAll method testNull.
@Test
public void testNull() throws HiveException {
udf = new GenericUDFLikeAll();
ObjectInspector valueOIOne = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector valueOITwo = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector valueOIThree = PrimitiveObjectInspectorFactory.writableVoidObjectInspector;
ObjectInspector[] arguments = { valueOIOne, valueOITwo, valueOIThree };
udf.initialize(arguments);
DeferredObject valueObjOne = new DeferredJavaObject(new Text("linkedin"));
DeferredObject valueObjTwo = new DeferredJavaObject(new Text("%oo%"));
DeferredObject valueObjThree = new DeferredJavaObject(NullWritable.get());
DeferredObject[] args = { valueObjOne, valueObjTwo, valueObjThree };
BooleanWritable output = (BooleanWritable) udf.evaluate(args);
assertEquals(null, output);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFLikeAll method expectException.
@Test(expected = UDFArgumentException.class)
public void expectException() throws HiveException {
udf = new GenericUDFLikeAll();
ObjectInspector valueOIOne = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector[] arguments = { valueOIOne };
udf.initialize(arguments);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFLikeAny method testNull.
@Test
public void testNull() throws HiveException {
udf = new GenericUDFLikeAny();
ObjectInspector valueOIOne = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector valueOITwo = PrimitiveObjectInspectorFactory.writableVoidObjectInspector;
ObjectInspector valueOIThree = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector[] arguments = { valueOIOne, valueOITwo, valueOIThree };
udf.initialize(arguments);
DeferredObject valueObjOne = new DeferredJavaObject(new Text("abc"));
DeferredObject valueObjTwo = new DeferredJavaObject(NullWritable.get());
DeferredObject valueObjThree = new DeferredJavaObject(new Text("%b%"));
DeferredObject[] args = { valueObjOne, valueObjTwo, valueObjThree };
BooleanWritable output = (BooleanWritable) udf.evaluate(args);
assertEquals(null, output);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFLikeAny method testTrue.
@Test
public void testTrue() throws HiveException {
udf = new GenericUDFLikeAny();
ObjectInspector valueOIOne = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector valueOITwo = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector valueOIThree = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector[] arguments = { valueOIOne, valueOITwo, valueOIThree };
udf.initialize(arguments);
DeferredJavaObject valueObjOne = new DeferredJavaObject(new Text("abc"));
DeferredJavaObject valueObjTwo = new DeferredJavaObject(new Text("%b%"));
HiveVarchar vc = new HiveVarchar();
vc.setValue("a%");
GenericUDF.DeferredJavaObject[] args = { valueObjOne, valueObjTwo, new GenericUDF.DeferredJavaObject(new HiveVarcharWritable(vc)) };
BooleanWritable output = (BooleanWritable) udf.evaluate(args);
assertEquals(true, output.get());
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFNextDay method testNextDay.
public void testNextDay() throws HiveException {
GenericUDFNextDay udf = new GenericUDFNextDay();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
// start_date is Sun, 2 letters day name
runAndVerify("2015-01-11", "su", "2015-01-18", udf);
runAndVerify("2015-01-11", "MO", "2015-01-12", udf);
runAndVerify("2015-01-11", "Tu", "2015-01-13", udf);
runAndVerify("2015-01-11", "wE", "2015-01-14", udf);
runAndVerify("2015-01-11", "th", "2015-01-15", udf);
runAndVerify("2015-01-11", "FR", "2015-01-16", udf);
runAndVerify("2015-01-11", "Sa", "2015-01-17", udf);
// start_date is Sat, 3 letters day name
runAndVerify("2015-01-17", "sun", "2015-01-18", udf);
runAndVerify("2015-01-17", "MON", "2015-01-19", udf);
runAndVerify("2015-01-17", "Tue", "2015-01-20", udf);
runAndVerify("2015-01-17", "weD", "2015-01-21", udf);
runAndVerify("2015-01-17", "tHu", "2015-01-22", udf);
runAndVerify("2015-01-17", "FrI", "2015-01-23", udf);
runAndVerify("2015-01-17", "SAt", "2015-01-24", udf);
// start_date is Wed, full timestamp, full day name
runAndVerify("2015-01-14 14:04:34", "sunday", "2015-01-18", udf);
runAndVerify("2015-01-14 14:04:34.1", "Monday", "2015-01-19", udf);
runAndVerify("2015-01-14 14:04:34.100", "Tuesday", "2015-01-20", udf);
runAndVerify("2015-01-14 14:04:34.001", "wednesday", "2015-01-21", udf);
runAndVerify("2015-01-14 14:04:34.000000001", "thursDAY", "2015-01-15", udf);
runAndVerify("2015-01-14 14:04:34", "FRIDAY", "2015-01-16", udf);
runAndVerify("2015-01-14 14:04:34", "SATurday", "2015-01-17", udf);
// null values
runAndVerify("2015-01-14", null, null, udf);
runAndVerify(null, "SU", null, udf);
runAndVerify(null, null, null, udf);
}
Aggregations