use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector in project hive by apache.
the class TestStreamingAvg method avgHiveDecimal.
public void avgHiveDecimal(Iterator<HiveDecimal> inVals, int inSz, int numPreceding, int numFollowing, Iterator<HiveDecimal> outVals) throws HiveException {
GenericUDAFAverage fnR = new GenericUDAFAverage();
TypeInfo[] inputTypes = { TypeInfoFactory.decimalTypeInfo };
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector };
HiveDecimalWritable[] in = new HiveDecimalWritable[1];
in[0] = new HiveDecimalWritable();
TestStreamingSum._agg(fnR, inputTypes, inVals, TypeHandler.HiveDecimalHandler, in, inputOIs, inSz, numPreceding, numFollowing, outVals);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector in project hive by apache.
the class TestGenericUDFBRound method testDecimal.
@Test
public void testDecimal() throws HiveException {
GenericUDFBRound udf = new GenericUDFBRound();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector;
IntWritable scale = new IntWritable(0);
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.intTypeInfo, scale);
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
runDecimal(2.5, scale, 2.0, udf);
runDecimal(3.5, scale, 4.0, udf);
runDecimal(2.49, scale, 2.0, udf);
runDecimal(3.49, scale, 3.0, udf);
runDecimal(2.51, scale, 3.0, udf);
runDecimal(3.51, scale, 4.0, udf);
runDecimal(2.4, scale, 2.0, udf);
runDecimal(3.4, scale, 3.0, udf);
runDecimal(2.6, scale, 3.0, udf);
runDecimal(3.6, scale, 4.0, udf);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector in project hive by apache.
the class TestStreamingSum method sumHiveDecimal.
public void sumHiveDecimal(Iterator<HiveDecimal> inVals, int inSz, int numPreceding, int numFollowing, Iterator<HiveDecimal> outVals) throws HiveException {
GenericUDAFSum fnR = new GenericUDAFSum();
TypeInfo[] inputTypes = { TypeInfoFactory.decimalTypeInfo };
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector };
HiveDecimalWritable[] in = new HiveDecimalWritable[1];
in[0] = new HiveDecimalWritable();
_agg(fnR, inputTypes, inVals, TypeHandler.HiveDecimalHandler, in, inputOIs, inSz, numPreceding, numFollowing, outVals);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector in project hive by apache.
the class TestGenericUDFRound method getExpectedResult.
@Override
public InspectableObject[] getExpectedResult() {
DataBuilder db = new DataBuilder();
db.setColumnNames("_col1", "_col2", "_col3", "_col4", "_col5", "_col6", "_col7", "_col8");
db.setColumnTypes(PrimitiveObjectInspectorFactory.javaStringObjectInspector, PrimitiveObjectInspectorFactory.writableIntObjectInspector, PrimitiveObjectInspectorFactory.writableDoubleObjectInspector, PrimitiveObjectInspectorFactory.writableFloatObjectInspector, PrimitiveObjectInspectorFactory.writableByteObjectInspector, PrimitiveObjectInspectorFactory.writableShortObjectInspector, PrimitiveObjectInspectorFactory.writableLongObjectInspector, PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector);
db.addRow(null, new IntWritable(170), new DoubleWritable(1.1), new FloatWritable(32f), new ByteWritable((byte) 0), new ShortWritable((short) 1234), new LongWritable(123500L), new HiveDecimalWritable(HiveDecimal.create("983.724")));
db.addRow(new DoubleWritable(-200), null, null, new FloatWritable(0f), new ByteWritable((byte) 100), new ShortWritable((short) 551), new LongWritable(900L), new HiveDecimalWritable(HiveDecimal.create("983723.005")));
db.addRow(new DoubleWritable(500), new IntWritable(22345), new DoubleWritable(-23.000), new FloatWritable(-3f), new ByteWritable((byte) 100), new ShortWritable((short) 2321), new LongWritable(9200L), new HiveDecimalWritable(HiveDecimal.create("-932032.7")));
return db.createRows();
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector in project hive by apache.
the class TestValueBoundaryScanner method testHiveDecimalEquals.
@Test
public void testHiveDecimalEquals() {
PTFExpressionDef argDef = new PTFExpressionDef();
argDef.setOI(PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector);
HiveDecimalValueBoundaryScanner scanner = new HiveDecimalValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
HiveDecimalWritable w1 = new HiveDecimalWritable(1);
HiveDecimalWritable w2 = new HiveDecimalWritable(2);
Assert.assertTrue(scanner.isEqual(w1, w1));
Assert.assertFalse(scanner.isEqual(w1, w2));
Assert.assertFalse(scanner.isEqual(w2, w1));
Assert.assertFalse(scanner.isEqual(null, w2));
Assert.assertFalse(scanner.isEqual(w1, null));
Assert.assertTrue(scanner.isEqual(null, null));
}
Aggregations