use of org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector in project hive by apache.
the class TestGenericUDFQuarter method testQuarterDt.
public void testQuarterDt() throws HiveException {
GenericUDFQuarter udf = new GenericUDFQuarter();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
ObjectInspector[] arguments = { valueOI0 };
udf.initialize(arguments);
// positive Unix time
runAndVerifyDt("2014-01-01", 1, udf);
runAndVerifyDt("2014-02-10", 1, udf);
runAndVerifyDt("2014-03-31", 1, udf);
runAndVerifyDt("2014-04-02", 2, udf);
runAndVerifyDt("2014-05-28", 2, udf);
runAndVerifyDt("2016-06-03", 2, udf);
runAndVerifyDt("2016-07-28", 3, udf);
runAndVerifyDt("2016-08-29", 3, udf);
runAndVerifyDt("2016-09-29", 3, udf);
runAndVerifyDt("2016-10-29", 4, udf);
runAndVerifyDt("2016-11-29", 4, udf);
runAndVerifyDt("2016-12-31", 4, udf);
// negative Unix time
runAndVerifyDt("1966-01-01", 1, udf);
runAndVerifyDt("1966-03-31", 1, udf);
runAndVerifyDt("1966-04-01", 2, udf);
runAndVerifyDt("1966-12-31", 4, udf);
}
use of org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector 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.ObjectInspector 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.ObjectInspector 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.ObjectInspector 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);
}
Aggregations