Search in sources :

Example 61 with DecimalTypeInfo

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

the class TestTypeInfoUtils method testDecimal.

public void testDecimal() {
    DecimalTestCase[] testCases = { new DecimalTestCase("decimal", 10, 0), new DecimalTestCase("decimal(1)", 1, 0), new DecimalTestCase("decimal(25)", 25, 0), new DecimalTestCase("decimal(2,0)", 2, 0), new DecimalTestCase("decimal(2,1)", 2, 1), new DecimalTestCase("decimal(25,10)", 25, 10), new DecimalTestCase("decimal(38,20)", 38, 20) };
    for (DecimalTestCase testCase : testCases) {
        TypeInfo typeInfo = TypeInfoUtils.getTypeInfoFromTypeString(testCase.typeString);
        DecimalTypeInfo decimalType = (DecimalTypeInfo) typeInfo;
        assertEquals("Failed for " + testCase.typeString, testCase.expectedPrecision, decimalType.getPrecision());
        assertEquals("Failed for " + testCase.typeString, testCase.expectedScale, decimalType.getScale());
    }
}
Also used : TypeInfo(org.apache.hadoop.hive.serde2.typeinfo.TypeInfo)

Aggregations

DecimalTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo)53 PrimitiveTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo)23 HiveDecimalWritable (org.apache.hadoop.hive.serde2.io.HiveDecimalWritable)21 HiveDecimal (org.apache.hadoop.hive.common.type.HiveDecimal)16 HiveVarchar (org.apache.hadoop.hive.common.type.HiveVarchar)16 HiveChar (org.apache.hadoop.hive.common.type.HiveChar)15 CharTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.CharTypeInfo)15 VarcharTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeInfo)15 IntWritable (org.apache.hadoop.io.IntWritable)15 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)14 Date (java.sql.Date)13 Timestamp (java.sql.Timestamp)13 TypeInfo (org.apache.hadoop.hive.serde2.typeinfo.TypeInfo)13 DoubleWritable (org.apache.hadoop.hive.serde2.io.DoubleWritable)12 ShortWritable (org.apache.hadoop.hive.serde2.io.ShortWritable)12 BooleanWritable (org.apache.hadoop.io.BooleanWritable)12 BytesWritable (org.apache.hadoop.io.BytesWritable)12 FloatWritable (org.apache.hadoop.io.FloatWritable)12 LongWritable (org.apache.hadoop.io.LongWritable)12 ArrayList (java.util.ArrayList)11