use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFQuarter method testQuarterStr.
public void testQuarterStr() throws HiveException {
GenericUDFQuarter udf = new GenericUDFQuarter();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector[] arguments = { valueOI0 };
udf.initialize(arguments);
// date str
runAndVerifyStr("2014-01-10", 1, udf);
runAndVerifyStr("2014-02-10", 1, udf);
runAndVerifyStr("2014-03-31", 1, udf);
runAndVerifyStr("2014-04-02", 2, udf);
runAndVerifyStr("2014-05-28", 2, udf);
runAndVerifyStr("2016-06-03", 2, udf);
runAndVerifyStr("2016-07-28", 3, udf);
runAndVerifyStr("2016-08-29", 3, udf);
runAndVerifyStr("2016-09-29", 3, udf);
runAndVerifyStr("2016-10-29", 4, udf);
runAndVerifyStr("2016-11-29", 4, udf);
runAndVerifyStr("2016-12-29", 4, udf);
// negative Unix time
runAndVerifyStr("1966-01-01", 1, udf);
runAndVerifyStr("1966-03-31", 1, udf);
runAndVerifyStr("1966-04-01", 2, udf);
runAndVerifyStr("1966-12-31", 4, udf);
// ts str
runAndVerifyStr("2014-01-01 00:00:00", 1, udf);
runAndVerifyStr("2014-02-10 15:23:00", 1, udf);
runAndVerifyStr("2014-03-31 15:23:00", 1, udf);
runAndVerifyStr("2014-04-02 15:23:00", 2, udf);
runAndVerifyStr("2014-05-28 15:23:00", 2, udf);
runAndVerifyStr("2016-06-03 15:23:00", 2, udf);
runAndVerifyStr("2016-07-28 15:23:00", 3, udf);
runAndVerifyStr("2016-08-29 15:23:00", 3, udf);
runAndVerifyStr("2016-09-29 15:23:00", 3, udf);
runAndVerifyStr("2016-10-29 15:23:00", 4, udf);
runAndVerifyStr("2016-11-29 15:23:00", 4, udf);
runAndVerifyStr("2016-12-31 23:59:59.999", 4, udf);
// negative Unix time
runAndVerifyStr("1966-01-01 00:00:00", 1, udf);
runAndVerifyStr("1966-03-31 23:59:59.999", 1, udf);
runAndVerifyStr("1966-04-01 00:00:00", 2, udf);
runAndVerifyStr("1966-12-31 23:59:59.999", 4, 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("\u3500\u3501\u3502\u3503", null, udf);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFFloor method testString.
@Test
public void testString() throws HiveException {
GenericUDFFloor udf = new GenericUDFFloor();
Text input = new Text("32300.004747");
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableStringObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(input) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.longTypeInfo, oi.getTypeInfo());
LongWritable res = (LongWritable) udf.evaluate(args);
Assert.assertEquals(32300L, res.get());
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFFromUtcTimestamp method testToUtcTimestamp.
public void testToUtcTimestamp() throws Exception {
ObjectInspector valueOI = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
GenericUDFToUtcTimestamp udf = new GenericUDFToUtcTimestamp();
ObjectInspector[] args2 = { valueOI, valueOI };
udf.initialize(args2);
runAndVerify(udf, new Text("2015-03-28 17:00:00"), new Text("Europe/London"), Timestamp.valueOf("2015-03-28 17:00:00"));
runAndVerify(udf, new Text("2015-03-28 18:00:00"), new Text("Europe/London"), Timestamp.valueOf("2015-03-28 18:00:00"));
runAndVerify(udf, new Text("2015-03-28 19:00:00"), new Text("Europe/London"), Timestamp.valueOf("2015-03-28 19:00:00"));
// Make sure nanos are preserved
runAndVerify(udf, new Text("2015-03-28 18:00:00.123456789"), new Text("Europe/London"), Timestamp.valueOf("2015-03-28 18:00:00.123456789"));
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFGreatest method testVoids.
public void testVoids() throws HiveException {
GenericUDFGreatest udf = new GenericUDFGreatest();
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableVoidObjectInspector;
ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
ObjectInspector valueOI3 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector[] arguments = { valueOI1, valueOI2, valueOI3 };
udf.initialize(arguments);
runAndVerify(new Object[] { null, 1, "test" }, null, udf);
}
Aggregations