use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.stringTypeInfo in project hive by apache.
the class TestGenericUDFAddMonths method testAddMonthsWithNullFormatter.
@Test
public void testAddMonthsWithNullFormatter() throws HiveException {
GenericUDFAddMonths udf = new GenericUDFAddMonths();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.stringTypeInfo, null);
ObjectInspector[] arguments = { valueOI0, valueOI1, valueOI2 };
udf.initialize(arguments);
runAndVerify("2017-12-31 14:15:16.350", 2, null, "2018-02-28", udf);
runAndVerify("2017-12-31", 2, null, "2018-02-28", udf);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.stringTypeInfo in project hive by apache.
the class TestGenericUDFAddMonths method testAddMonthsStringWithTime.
@Test
public void testAddMonthsStringWithTime() throws HiveException {
GenericUDFAddMonths udf = new GenericUDFAddMonths();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.stringTypeInfo, fmtTextWithTime);
ObjectInspector[] arguments = { valueOI0, valueOI1, valueOI2 };
udf.initialize(arguments);
runAndVerify("2018-05-10 08:15:12", -1, fmtTextWithTime, "2018-04-10 08:15:12", udf);
runAndVerify("2017-12-31 14:15:16", 2, fmtTextWithTime, "2018-02-28 14:15:16", udf);
runAndVerify("2017-12-31 14:15:16.001", 2, fmtTextWithTime, "2018-02-28 14:15:16", udf);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.stringTypeInfo in project hive by apache.
the class TestGenericUDFAddMonths method testAddMonthsStringWithTimeWithms.
@Test
public void testAddMonthsStringWithTimeWithms() throws HiveException {
GenericUDFAddMonths udf = new GenericUDFAddMonths();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.stringTypeInfo, fmtTextWithTimeAndms);
ObjectInspector[] arguments = { valueOI0, valueOI1, valueOI2 };
udf.initialize(arguments);
runAndVerify("2017-12-31 14:15:16.350", 2, fmtTextWithTimeAndms, "2018-02-28 14:15:16.350", udf);
runAndVerify("2017-12-31 14:15:16.001", 2, fmtTextWithTimeAndms, "2018-02-28 14:15:16.001", udf);
// Try to parse ms where there is no millisecond part in input, expected to return .000 as ms
runAndVerify("2017-12-31 14:15:16", 2, fmtTextWithTimeAndms, "2018-02-28 14:15:16.000", udf);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.stringTypeInfo in project hive by apache.
the class TestGenericUDFAesEncrypt method testAesEnc256ConstStr.
@Test
public void testAesEnc256ConstStr() throws HiveException, NoSuchAlgorithmException {
int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES");
// Jurisdiction Policy Files not installed
if (maxKeyLen < 256) {
return;
}
GenericUDFAesEncrypt udf = new GenericUDFAesEncrypt();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
Text keyWr = new Text("1234567890123456" + "1234567890123456");
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.stringTypeInfo, keyWr);
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
runAndVerifyStr("ABC", keyWr, "nYfCuJeRd5eD60yXDw7WEA==", udf);
runAndVerifyStr("", keyWr, "mVClVqZ6W4VF6b842FOgCA==", udf);
// null
runAndVerifyStr(null, keyWr, null, udf);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.stringTypeInfo in project hive by apache.
the class TestGenericUDFAesEncrypt method testAesEncKeyNullConstStr.
@Test
public void testAesEncKeyNullConstStr() throws HiveException {
GenericUDFAesEncrypt udf = new GenericUDFAesEncrypt();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
Text keyWr = null;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.stringTypeInfo, keyWr);
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
runAndVerifyStr("ABC", keyWr, null, udf);
}
Aggregations