use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFAbs method testText.
public void testText() throws HiveException {
GenericUDFAbs udf = new GenericUDFAbs();
ObjectInspector valueOI = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector[] arguments = { valueOI };
udf.initialize(arguments);
DeferredObject valueObj = new DeferredJavaObject(new Text("123.45"));
DeferredObject[] args = { valueObj };
DoubleWritable output = (DoubleWritable) udf.evaluate(args);
assertEquals("abs() test for String failed ", "123.45", output.toString());
valueObj = new DeferredJavaObject(new Text("-123.45"));
args[0] = valueObj;
output = (DoubleWritable) udf.evaluate(args);
assertEquals("abs() test for String failed ", "123.45", output.toString());
valueObj = new DeferredJavaObject(new Text("foo"));
args[0] = valueObj;
output = (DoubleWritable) udf.evaluate(args);
assertEquals("abs() test for String failed ", null, output);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFAddMonths method testAddMonthsByte.
public void testAddMonthsByte() throws HiveException {
GenericUDFAddMonths udf = new GenericUDFAddMonths();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableByteObjectInspector;
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
// short
runAndVerify("2014-01-14", (byte) 1, "2014-02-14", udf);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFAddMonths method testAddMonthsLong.
public void testAddMonthsLong() throws HiveException {
@SuppressWarnings("resource") GenericUDFAddMonths udf = new GenericUDFAddMonths();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableLongObjectInspector;
ObjectInspector[] arguments = { valueOI0, valueOI1 };
try {
udf.initialize(arguments);
assertTrue("add_months exception expected", false);
} catch (UDFArgumentTypeException e) {
assertEquals("add_months test", "add_months only takes INT/SHORT/BYTE types as 2nd argument, got LONG", e.getMessage());
}
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFAesDecrypt method testAesDecKeyNullStr.
@Test
public void testAesDecKeyNullStr() throws HiveException {
GenericUDFAesDecrypt udf = new GenericUDFAesDecrypt();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
Text keyWr = null;
runAndVerifyStr("y6Ss+zCYObpCbgfWfyNWTw==", keyWr, null, udf);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFAesEncrypt method testAesEnc128Str.
@Test
public void testAesEnc128Str() throws HiveException {
GenericUDFAesEncrypt udf = new GenericUDFAesEncrypt();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
Text keyWr = new Text("1234567890123456");
runAndVerifyStr("ABC", keyWr, "y6Ss+zCYObpCbgfWfyNWTw==", udf);
runAndVerifyStr("", keyWr, "BQGHoM3lqYcsurCRq3PlUw==", udf);
// null
runAndVerifyStr(null, keyWr, null, udf);
}
Aggregations