use of org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject in project hive by apache.
the class TestGenericUDFSubstringIndex method runAndVerify.
private void runAndVerify(String str, String delim, Integer count, String expResult, GenericUDF udf) throws HiveException {
DeferredObject valueObj0 = new DeferredJavaObject(str != null ? new Text(str) : null);
DeferredObject valueObj1 = new DeferredJavaObject(delim != null ? new Text(delim) : delim);
DeferredObject valueObj2 = new DeferredJavaObject(count != null ? new IntWritable(count) : null);
DeferredObject[] args = { valueObj0, valueObj1, valueObj2 };
Text output = (Text) udf.evaluate(args);
assertEquals("substring_index() test ", expResult, output != null ? output.toString() : null);
}
use of org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject in project hive by apache.
the class TestGenericUDFInternalInterval method testDayInterval.
@Test
public void testDayInterval() throws Exception {
try (GenericUDFInternalInterval udf = new GenericUDFInternalInterval()) {
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.intTypeInfo, new IntWritable(HiveParser.TOK_INTERVAL_DAY_LITERAL)), PrimitiveObjectInspectorFactory.writableStringObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(new ByteWritable((byte) 4)), new DeferredJavaObject(new Text("8")) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.intervalDayTimeTypeInfo, oi.getTypeInfo());
HiveIntervalDayTimeWritable res = (HiveIntervalDayTimeWritable) udf.evaluate(args);
Assert.assertEquals(8, res.getHiveIntervalDayTime().getDays());
}
}
use of org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject in project hive by apache.
the class TestGenericUDFLastDay method runAndVerify.
private void runAndVerify(String str, String expResult, GenericUDF udf) throws HiveException {
DeferredObject valueObj0 = new DeferredJavaObject(str != null ? new Text(str) : null);
DeferredObject[] args = { valueObj0 };
Text output = (Text) udf.evaluate(args);
assertEquals("last_day() test ", expResult, output != null ? output.toString() : null);
}
use of org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject in project hive by apache.
the class TestGenericUDFLeast method runAndVerify.
private void runAndVerify(Object[] v, Object expResult, GenericUDF udf) throws HiveException {
DeferredObject[] args = new DeferredObject[v.length];
for (int i = 0; i < v.length; i++) {
args[i] = new DeferredJavaObject(getWritable(v[i]));
}
Object output = udf.evaluate(args);
output = parseOutput(output);
assertEquals("greatest() test ", expResult, output != null ? output : null);
}
use of org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject in project hive by apache.
the class TestGenericUDFNextDay method runAndVerify.
private void runAndVerify(String date, String dayOfWeek, String expResult, GenericUDF udf) throws HiveException {
DeferredObject valueObj0 = new DeferredJavaObject(date != null ? new Text(date) : null);
DeferredObject valueObj1 = new DeferredJavaObject(dayOfWeek != null ? new Text(dayOfWeek) : null);
DeferredObject[] args = { valueObj0, valueObj1 };
Text output = (Text) udf.evaluate(args);
assertEquals("next_day() test ", expResult, output != null ? output.toString() : null);
}
Aggregations