use of org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector in project hive by apache.
the class TestGenericUDFOPMod method testModByZero6.
@Test
public void testModByZero6() throws HiveException {
GenericUDFOPMod udf = new GenericUDFOPMod();
// Double
DoubleWritable d1 = new DoubleWritable(4.5);
DoubleWritable d2 = new DoubleWritable(0.0);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableDoubleObjectInspector, PrimitiveObjectInspectorFactory.writableDoubleObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(d1), new DeferredJavaObject(d2) };
udf.initialize(inputOIs);
DoubleWritable d3 = (DoubleWritable) udf.evaluate(args);
Assert.assertNull(d3);
}
use of org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector in project hive by apache.
the class TestGenericUDFOPMod method testModByZero4.
@Test
public void testModByZero4() throws HiveException {
GenericUDFOPMod udf = new GenericUDFOPMod();
// Long
LongWritable l1 = new LongWritable(4);
LongWritable l2 = new LongWritable(0L);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableLongObjectInspector, PrimitiveObjectInspectorFactory.writableLongObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(l1), new DeferredJavaObject(l2) };
udf.initialize(inputOIs);
LongWritable l3 = (LongWritable) udf.evaluate(args);
Assert.assertNull(l3);
}
use of org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector in project hive by apache.
the class TestGenericUDFOPMultiply method testDoubleTimesLong.
@Test
public void testDoubleTimesLong() throws HiveException {
GenericUDFOPMultiply udf = new GenericUDFOPMultiply();
DoubleWritable left = new DoubleWritable(4.5);
LongWritable right = new LongWritable(10);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableDoubleObjectInspector, PrimitiveObjectInspectorFactory.writableLongObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(left), new DeferredJavaObject(right) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.doubleTypeInfo, oi.getTypeInfo());
DoubleWritable res = (DoubleWritable) udf.evaluate(args);
Assert.assertEquals(new Double(45.0), new Double(res.get()));
}
use of org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector in project hive by apache.
the class TestGenericUDFOPMultiply method testFloatTimesFloat.
@Test
public void testFloatTimesFloat() throws HiveException {
GenericUDFOPMultiply udf = new GenericUDFOPMultiply();
FloatWritable f1 = new FloatWritable(4.5f);
FloatWritable f2 = new FloatWritable(0.0f);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableFloatObjectInspector, PrimitiveObjectInspectorFactory.writableFloatObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(f1), new DeferredJavaObject(f2) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(oi.getTypeInfo(), TypeInfoFactory.floatTypeInfo);
FloatWritable res = (FloatWritable) udf.evaluate(args);
Assert.assertEquals(new Float(0.0), new Float(res.get()));
}
use of org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector in project hive by apache.
the class TestGenericUDFOPMultiply method testDecimalTimesDecimalSameParams.
@Test
public void testDecimalTimesDecimalSameParams() throws HiveException {
GenericUDFOPMultiply udf = new GenericUDFOPMultiply();
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(TypeInfoFactory.getDecimalTypeInfo(5, 2)), PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(TypeInfoFactory.getDecimalTypeInfo(5, 2)) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.getDecimalTypeInfo(11, 4), oi.getTypeInfo());
}
Aggregations