use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFRTrim method testTrim.
public void testTrim() throws HiveException {
GenericUDFRTrim udf = new GenericUDFRTrim();
ObjectInspector valueOI = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector[] arguments = { valueOI };
udf.initialize(arguments);
runAndVerify(" Hello World! ", " Hello World!", udf);
runAndVerify("Hello World! ", "Hello World!", udf);
runAndVerify(" Hello World!", " Hello World!", udf);
runAndVerify("Hello World!", "Hello World!", udf);
runAndVerify(" ", "", udf);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFRegexp method testConstant.
public void testConstant() throws HiveException {
GenericUDFRegExp udf = new GenericUDFRegExp();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
Text regexText = new Text("^fo");
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.stringTypeInfo, regexText);
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
runAndVerifyConst("fofo", regexText, true, udf);
runAndVerifyConst("fofofo", regexText, true, udf);
runAndVerifyConst("fobar", regexText, true, udf);
runAndVerifyConst("barfobar", regexText, false, udf);
// null
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 testEmptyConstant.
public void testEmptyConstant() throws HiveException {
GenericUDFRegExp udf = new GenericUDFRegExp();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
Text regexText = new Text("");
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.stringTypeInfo, regexText);
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
// empty regex (should be one WARN message)
runAndVerifyConst("foo", regexText, false, udf);
runAndVerifyConst("bar", regexText, false, udf);
// null
runAndVerifyConst(null, regexText, null, udf);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFSoundex method testSoundex.
public void testSoundex() throws HiveException {
GenericUDFSoundex udf = new GenericUDFSoundex();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector[] arguments = { valueOI0 };
udf.initialize(arguments);
runAndVerify("Miller", "M460", udf);
runAndVerify("miler", "M460", udf);
runAndVerify("myller", "M460", udf);
runAndVerify("muller", "M460", udf);
runAndVerify("m", "M000", udf);
runAndVerify("mu", "M000", udf);
runAndVerify("mil", "M400", udf);
runAndVerify("Peterson", "P362", udf);
runAndVerify("Pittersen", "P362", udf);
runAndVerify("", "", udf);
runAndVerify(null, null, udf);
runAndVerify("㔀㔁㔂㔃", null, udf);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFSubstringIndex method testSubstringIndex.
public void testSubstringIndex() throws HiveException {
GenericUDFSubstringIndex udf = new GenericUDFSubstringIndex();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
ObjectInspector[] arguments = { valueOI0, valueOI1, valueOI2 };
udf.initialize(arguments);
runAndVerify("www.apache.org", ".", 3, "www.apache.org", udf);
runAndVerify("www.apache.org", ".", 2, "www.apache", udf);
runAndVerify("www.apache.org", ".", 1, "www", udf);
runAndVerify("www.apache.org", ".", 0, "", udf);
runAndVerify("www.apache.org", ".", -1, "org", udf);
runAndVerify("www.apache.org", ".", -2, "apache.org", udf);
runAndVerify("www.apache.org", ".", -3, "www.apache.org", udf);
// str is empty string
runAndVerify("", ".", 1, "", udf);
// empty string delim
runAndVerify("www.apache.org", "", 1, "", udf);
// delim does not exist in str
runAndVerify("www.apache.org", "-", 2, "www.apache.org", udf);
// delim is 2 chars
runAndVerify("www||apache||org", "||", 2, "www||apache", udf);
// null
runAndVerify(null, ".", 2, null, udf);
runAndVerify("www.apache.org", null, 2, null, udf);
runAndVerify("www.apache.org", ".", null, null, udf);
}
Aggregations