use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.longTypeInfo in project hive by apache.
the class TestGenericUDFCeil method testLong.
@Test
public void testLong() throws HiveException {
GenericUDFCeil udf = new GenericUDFCeil();
LongWritable input = new LongWritable(3234747);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableLongObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(input) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.longTypeInfo, oi.getTypeInfo());
LongWritable res = (LongWritable) udf.evaluate(args);
Assert.assertEquals(3234747L, res.get());
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.longTypeInfo in project hive by apache.
the class TestGenericUDFCeil method testChar.
@Test
public void testChar() throws HiveException {
GenericUDFCeil udf = new GenericUDFCeil();
HiveChar vc = new HiveChar("-32300.004747", 12);
HiveCharWritable input = new HiveCharWritable(vc);
CharTypeInfo inputTypeInfo = TypeInfoFactory.getCharTypeInfo(12);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(inputTypeInfo) };
DeferredObject[] args = { new DeferredJavaObject(input) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.longTypeInfo, oi.getTypeInfo());
LongWritable res = (LongWritable) udf.evaluate(args);
Assert.assertEquals(-32300L, res.get());
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.longTypeInfo in project hive by apache.
the class TestStreamingMax method maxLong.
public void maxLong(Iterator<Long> inVals, int inSz, int numPreceding, int numFollowing, Iterator<Long> outVals) throws HiveException {
GenericUDAFMax fnR = new GenericUDAFMax();
TypeInfo[] inputTypes = { TypeInfoFactory.longTypeInfo };
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableLongObjectInspector };
LongWritable[] in = new LongWritable[1];
in[0] = new LongWritable();
TestStreamingSum._agg(fnR, inputTypes, inVals, TypeHandler.LongHandler, in, inputOIs, inSz, numPreceding, numFollowing, outVals);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.longTypeInfo in project hive by apache.
the class TestGenericUDFCeil method testFloat.
@Test
public void testFloat() throws HiveException {
GenericUDFCeil udf = new GenericUDFCeil();
FloatWritable input = new FloatWritable(323.4747f);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableFloatObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(input) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.longTypeInfo, oi.getTypeInfo());
LongWritable res = (LongWritable) udf.evaluate(args);
Assert.assertEquals(324L, res.get());
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.longTypeInfo in project hive by apache.
the class TestFunctionRegistry method testImplicitConversion.
public void testImplicitConversion() {
implicit(TypeInfoFactory.intTypeInfo, TypeInfoFactory.decimalTypeInfo, true);
implicit(TypeInfoFactory.longTypeInfo, TypeInfoFactory.decimalTypeInfo, true);
implicit(TypeInfoFactory.floatTypeInfo, TypeInfoFactory.decimalTypeInfo, false);
implicit(TypeInfoFactory.doubleTypeInfo, TypeInfoFactory.decimalTypeInfo, false);
implicit(TypeInfoFactory.stringTypeInfo, TypeInfoFactory.decimalTypeInfo, false);
implicit(TypeInfoFactory.dateTypeInfo, TypeInfoFactory.decimalTypeInfo, false);
implicit(TypeInfoFactory.timestampTypeInfo, TypeInfoFactory.decimalTypeInfo, false);
implicit(varchar10, TypeInfoFactory.stringTypeInfo, true);
implicit(TypeInfoFactory.stringTypeInfo, varchar10, true);
// Try with parameterized varchar types
TypeInfo varchar10 = TypeInfoFactory.getPrimitiveTypeInfo("varchar(10)");
TypeInfo varchar20 = TypeInfoFactory.getPrimitiveTypeInfo("varchar(20)");
implicit(varchar10, TypeInfoFactory.stringTypeInfo, true);
implicit(varchar20, TypeInfoFactory.stringTypeInfo, true);
implicit(TypeInfoFactory.stringTypeInfo, varchar10, true);
implicit(TypeInfoFactory.stringTypeInfo, varchar20, true);
implicit(varchar20, varchar10, true);
implicit(char10, TypeInfoFactory.stringTypeInfo, true);
implicit(TypeInfoFactory.stringTypeInfo, char10, true);
implicit(char5, char10, true);
implicit(char5, varchar10, true);
implicit(varchar5, char10, true);
implicit(TypeInfoFactory.intTypeInfo, char10, true);
implicit(TypeInfoFactory.intTypeInfo, varchar10, true);
implicit(TypeInfoFactory.intTypeInfo, TypeInfoFactory.stringTypeInfo, true);
}
Aggregations