Examples of DecimalTypeInfo


Examples of org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo

    inputType = inputOI.getPrimitiveCategory();
    ObjectInspector outputOI = null;
    switch (inputType) {
    case DECIMAL:
      DecimalTypeInfo inputTypeInfo = (DecimalTypeInfo) inputOI.getTypeInfo();
      DecimalTypeInfo typeInfo = getOutputTypeInfo(inputTypeInfo, scale);
      outputOI = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(typeInfo);
      break;
    case VOID:
    case BYTE:
    case SHORT:
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo

  @Test
  public void testDecimal() throws HiveException {
    GenericUDFFloor udf = new GenericUDFFloor();

    HiveDecimalWritable input = new HiveDecimalWritable(HiveDecimal.create("32300.004747"));
    DecimalTypeInfo inputTypeInfo = TypeInfoFactory.getDecimalTypeInfo(11, 6);
    ObjectInspector[] inputOIs = {
        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(inputTypeInfo),
    };
    DeferredObject[] args = {
        new DeferredJavaObject(input)
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo

    ObjectInspector[] inputOIs = {
        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(TypeInfoFactory.getDecimalTypeInfo(7, 3)),
        PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.intTypeInfo, new IntWritable(2))
    };
    PrimitiveObjectInspector outputOI = (PrimitiveObjectInspector) udf.initialize(inputOIs);
    DecimalTypeInfo outputTypeInfo = (DecimalTypeInfo)outputOI.getTypeInfo();
    Assert.assertEquals(TypeInfoFactory.getDecimalTypeInfo(7, 2), outputTypeInfo);
  }
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo

    ObjectInspector[] inputOIs = {
        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(TypeInfoFactory.getDecimalTypeInfo(7, 3)),
        PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.intTypeInfo, new IntWritable(-2))
    };
    PrimitiveObjectInspector outputOI = (PrimitiveObjectInspector) udf.initialize(inputOIs);
    DecimalTypeInfo outputTypeInfo = (DecimalTypeInfo)outputOI.getTypeInfo();
    Assert.assertEquals(TypeInfoFactory.getDecimalTypeInfo(5, 0), outputTypeInfo);
  }
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo

    ObjectInspector[] inputOIs = {
        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(TypeInfoFactory.getDecimalTypeInfo(7, 3)),
        PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.intTypeInfo, new IntWritable(5))
    };
    PrimitiveObjectInspector outputOI = (PrimitiveObjectInspector) udf.initialize(inputOIs);
    DecimalTypeInfo outputTypeInfo = (DecimalTypeInfo)outputOI.getTypeInfo();
    Assert.assertEquals(TypeInfoFactory.getDecimalTypeInfo(9, 5), outputTypeInfo);
  }
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo

            break;
          case DATE:
            type.setKind(OrcProto.Type.Kind.DATE);
            break;
          case DECIMAL:
            DecimalTypeInfo decTypeInfo = (DecimalTypeInfo)((PrimitiveObjectInspector)treeWriter.inspector).getTypeInfo();
            type.setKind(OrcProto.Type.Kind.DECIMAL);
            type.setPrecision(decTypeInfo.precision());
            type.setScale(decTypeInfo.scale());
            break;
          default:
            throw new IllegalArgumentException("Unknown primitive category: " +
              ((PrimitiveObjectInspector) treeWriter.inspector).
                getPrimitiveCategory());
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo

  @Test
  public void testDecimal() throws HiveException {
    GenericUDFOPNegative udf = new GenericUDFOPNegative();

    HiveDecimalWritable input = new HiveDecimalWritable(HiveDecimal.create("32300.004747"));
    DecimalTypeInfo inputTypeInfo = TypeInfoFactory.getDecimalTypeInfo(11, 6);
    ObjectInspector[] inputOIs = {
        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(inputTypeInfo),
    };
    DeferredObject[] args = {
        new DeferredJavaObject(input)
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo

  @Test
  public void testDecimal() throws HiveException {
    GenericUDFOPPositive udf = new GenericUDFOPPositive();

    HiveDecimalWritable input = new HiveDecimalWritable(HiveDecimal.create("32300.004747"));
    DecimalTypeInfo inputTypeInfo = TypeInfoFactory.getDecimalTypeInfo(11, 6);
    ObjectInspector[] inputOIs = {
        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(inputTypeInfo),
    };
    DeferredObject[] args = {
        new DeferredJavaObject(input)
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo

  @Test
  public void testFoldConstantsForUnaryExpression() throws HiveException {
    ExprNodeConstantDesc constDesc = new ExprNodeConstantDesc(new Integer(1));
    GenericUDFToDecimal udf = new GenericUDFToDecimal();
    udf.setTypeInfo(new DecimalTypeInfo(5, 2));
    List<ExprNodeDesc> children = new ArrayList<ExprNodeDesc>();
    children.add(constDesc);
    ExprNodeGenericFuncDesc exprDesc = new ExprNodeGenericFuncDesc();
    exprDesc.setGenericUDF(udf);
    exprDesc.setChildren(children);
    exprDesc.setTypeInfo(new DecimalTypeInfo(5, 2));
    Map<String, Integer> columnMap = new HashMap<String, Integer>();
    columnMap.put("col1", 1);
    VectorizationContext vc = new VectorizationContext(columnMap, 1);
    ExprNodeDesc constFoldNodeDesc = vc.foldConstantsForUnaryExpression(exprDesc);
    assertTrue(constFoldNodeDesc instanceof ExprNodeConstantDesc);
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo

            break;
          case STRING:
            result.cols[j] = new BytesColumnVector(VectorizedRowBatch.DEFAULT_SIZE);
            break;
          case DECIMAL:
            DecimalTypeInfo tInfo = (DecimalTypeInfo) poi.getTypeInfo();
            result.cols[j] = new DecimalColumnVector(VectorizedRowBatch.DEFAULT_SIZE,
                tInfo.precision(), tInfo.scale());
            break;
          default:
            throw new RuntimeException("Vectorizaton is not supported for datatype:"
                + poi.getPrimitiveCategory());
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.