Search in sources :

Example 16 with TypeInfoFactory.shortTypeInfo

use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.shortTypeInfo in project hive by apache.

the class TestGenericUDFOPNegative method testShort.

@Test
public void testShort() throws HiveException {
    GenericUDFOPNegative udf = new GenericUDFOPNegative();
    ShortWritable input = new ShortWritable((short) 74);
    ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableShortObjectInspector };
    DeferredObject[] args = { new DeferredJavaObject(input) };
    PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
    Assert.assertEquals(TypeInfoFactory.shortTypeInfo, oi.getTypeInfo());
    ShortWritable res = (ShortWritable) udf.evaluate(args);
    Assert.assertEquals((short) -74, res.get());
}
Also used : PrimitiveObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) DeferredJavaObject(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject) DeferredObject(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject) PrimitiveObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector) ShortWritable(org.apache.hadoop.hive.serde2.io.ShortWritable) Test(org.junit.Test)

Example 17 with TypeInfoFactory.shortTypeInfo

use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.shortTypeInfo in project hive by apache.

the class TestGenericUDFOPMinus method testByteMinusShort.

@Test
public void testByteMinusShort() throws HiveException {
    GenericUDFOPMinus udf = new GenericUDFOPMinus();
    ByteWritable left = new ByteWritable((byte) 4);
    ShortWritable right = new ShortWritable((short) 6);
    ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableByteObjectInspector, PrimitiveObjectInspectorFactory.writableShortObjectInspector };
    DeferredObject[] args = { new DeferredJavaObject(left), new DeferredJavaObject(right) };
    PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
    Assert.assertEquals(oi.getTypeInfo(), TypeInfoFactory.shortTypeInfo);
    ShortWritable res = (ShortWritable) udf.evaluate(args);
    Assert.assertEquals(-2, res.get());
}
Also used : PrimitiveObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) DeferredJavaObject(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject) DeferredObject(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject) PrimitiveObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector) ShortWritable(org.apache.hadoop.hive.serde2.io.ShortWritable) ByteWritable(org.apache.hadoop.hive.serde2.io.ByteWritable) Test(org.junit.Test)

Aggregations

DecimalTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo)10 TypeInfo (org.apache.hadoop.hive.serde2.typeinfo.TypeInfo)8 Test (org.junit.Test)7 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)6 HiveConf (org.apache.hadoop.hive.conf.HiveConf)5 SmallTableGenerationParameters (org.apache.hadoop.hive.ql.exec.vector.mapjoin.MapJoinTestDescription.SmallTableGenerationParameters)5 DeferredJavaObject (org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject)5 DeferredObject (org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject)5 ShortWritable (org.apache.hadoop.hive.serde2.io.ShortWritable)5 PrimitiveObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector)5 ByteWritable (org.apache.hadoop.hive.serde2.io.ByteWritable)3 ArrayList (java.util.ArrayList)2 Random (java.util.Random)2 ListTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.ListTypeInfo)2 MapTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.MapTypeInfo)2 StructTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.StructTypeInfo)2 List (java.util.List)1 Properties (java.util.Properties)1 DecimalType (org.apache.carbondata.core.metadata.datatype.DecimalType)1 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)1