use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.intTypeInfo in project hive by apache.
the class TestGenericUDFRound method testDecimalRoundingMetaData1.
@Test
public void testDecimalRoundingMetaData1() throws UDFArgumentException {
GenericUDFRound udf = new GenericUDFRound();
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(TypeInfoFactory.getDecimalTypeInfo(7, 3)), PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.intTypeInfo, new IntWritable(-2)) };
PrimitiveObjectInspector outputOI = (PrimitiveObjectInspector) udf.initialize(inputOIs);
DecimalTypeInfo outputTypeInfo = (DecimalTypeInfo) outputOI.getTypeInfo();
Assert.assertEquals(TypeInfoFactory.getDecimalTypeInfo(5, 0), outputTypeInfo);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.intTypeInfo in project hive by apache.
the class TestGenericUDFSha2 method testShaNullBin.
public void testShaNullBin() throws HiveException {
GenericUDFSha2 udf = new GenericUDFSha2();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
IntWritable lenWr = null;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.intTypeInfo, lenWr);
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
runAndVerifyBin(new byte[] { 65, 66, 67 }, lenWr, null, udf);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.intTypeInfo in project hive by apache.
the class TestGenericUDFSha2 method testSha0Bin.
public void testSha0Bin() throws HiveException {
GenericUDFSha2 udf = new GenericUDFSha2();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
IntWritable lenWr = new IntWritable(0);
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.intTypeInfo, lenWr);
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
runAndVerifyBin(new byte[] { 65, 66, 67 }, lenWr, "b5d4045c3f466fa91fe2cc6abe79232a1a57cdf104f7a26e716e0a1e2789df78", udf);
runAndVerifyBin(new byte[0], lenWr, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", udf);
// null
runAndVerifyBin(null, lenWr, null, udf);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.intTypeInfo in project hive by apache.
the class TestGenericUDFSha2 method testSha256Str.
public void testSha256Str() throws HiveException {
GenericUDFSha2 udf = new GenericUDFSha2();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
IntWritable lenWr = new IntWritable(256);
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.intTypeInfo, lenWr);
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
runAndVerifyStr("ABC", lenWr, "b5d4045c3f466fa91fe2cc6abe79232a1a57cdf104f7a26e716e0a1e2789df78", udf);
runAndVerifyStr("", lenWr, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", udf);
// null
runAndVerifyStr(null, lenWr, null, udf);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.intTypeInfo in project hive by apache.
the class TestGenericUDFInternalInterval method testDayIntervalConstant.
@Test
public void testDayIntervalConstant() throws Exception {
try (GenericUDFInternalInterval udf = new GenericUDFInternalInterval()) {
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.intTypeInfo, new IntWritable(HiveParser.TOK_INTERVAL_DAY_LITERAL)), PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.intTypeInfo, new IntWritable(3)) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.intervalDayTimeTypeInfo, oi.getTypeInfo());
ConstantObjectInspector coi = (ConstantObjectInspector) oi;
HiveIntervalDayTimeWritable res = (HiveIntervalDayTimeWritable) coi.getWritableConstantValue();
Assert.assertEquals(3, res.getHiveIntervalDayTime().getDays());
}
}
Aggregations