use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFInternalInterval method testNullBypass.
@Test
public void testNullBypass() 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(null) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.intervalDayTimeTypeInfo, oi.getTypeInfo());
HiveIntervalDayTimeWritable res = (HiveIntervalDayTimeWritable) udf.evaluate(args);
Assert.assertEquals(null, res);
}
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFRegexp method testNullConstant.
public void testNullConstant() throws HiveException {
GenericUDFRegExp udf = new GenericUDFRegExp();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
Text regexText = null;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.stringTypeInfo, regexText);
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
// null
runAndVerifyConst("fofo", regexText, null, udf);
runAndVerifyConst("fofofo", regexText, null, udf);
runAndVerifyConst("fobar", regexText, null, udf);
runAndVerifyConst(null, regexText, null, udf);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFRegexp method testNonConstant.
public void testNonConstant() throws HiveException {
GenericUDFRegExp udf = new GenericUDFRegExp();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
runAndVerify("fofo", "^fo", true, udf);
runAndVerify("fo\no", "^fo\no$", true, udf);
runAndVerify("Bn", "^Ba*n", true, udf);
runAndVerify("afofo", "fo", true, udf);
runAndVerify("afofo", "^fo", false, udf);
runAndVerify("Baan", "^Ba?n", false, udf);
runAndVerify("axe", "pi|apa", false, udf);
runAndVerify("pip", "^(pi)*$", false, udf);
// empty regex (should be one WARN message)
runAndVerify("bar", "", false, udf);
runAndVerify("foo", "", false, udf);
// null
runAndVerify(null, "^fo", null, udf);
runAndVerify("fofo", null, null, udf);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFNextDay method testNextDayErrorArg2.
public void testNextDayErrorArg2() throws HiveException {
@SuppressWarnings("resource") GenericUDFNextDay udf = new GenericUDFNextDay();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
ObjectInspector[] arguments = { valueOI0, valueOI1 };
try {
udf.initialize(arguments);
assertTrue("UDFArgumentException expected", false);
} catch (UDFArgumentException e) {
assertEquals("next_day only takes STRING_GROUP, VOID_GROUP types as 2nd argument, got INT", e.getMessage());
}
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFSubstringIndex method testSubstringIndexConst.
public void testSubstringIndexConst() throws HiveException {
GenericUDFSubstringIndex udf = new GenericUDFSubstringIndex();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
Text delim = new Text(".");
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.stringTypeInfo, delim);
IntWritable count = new IntWritable(2);
ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.intTypeInfo, count);
ObjectInspector[] arguments = { valueOI0, valueOI1, valueOI2 };
udf.initialize(arguments);
runAndVerifyConst("www.apache.org", "www.apache", udf);
}
Aggregations