Examples of PrimitiveTypeInfo


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

   */
  private TypeInfo updatePrecision(TypeInfo inputTypeInfo, DecimalTypeInfo returnType) {
    if (!(inputTypeInfo instanceof PrimitiveTypeInfo)) {
      return returnType;
    }
    PrimitiveTypeInfo ptinfo = (PrimitiveTypeInfo) inputTypeInfo;
    int precision = getPrecisionForType(ptinfo);
    int scale = HiveDecimalUtils.getScaleForType(ptinfo);
    return new DecimalTypeInfo(precision, scale);
  }
View Full Code Here

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

    }
    throw new HiveException("Unhandled cast input type: " + inputType);
  }

  private Decimal128 castConstantToDecimal(Object scalar, TypeInfo type) throws HiveException {
    PrimitiveTypeInfo ptinfo = (PrimitiveTypeInfo) type;
    String typename = type.getTypeName();
    Decimal128 d = new Decimal128();
    int scale = HiveDecimalUtils.getScaleForType(ptinfo);
    switch (ptinfo.getPrimitiveCategory()) {
      case FLOAT:
        float floatVal = ((Float) scalar).floatValue();
        d.update(floatVal, (short) scale);
        break;
      case DOUBLE:
View Full Code Here

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

        String type = colTypes.get(key);
        if (type == null) {
          throw new SemanticException("Column " + key + " not found");
        }
        // Create the corresponding hive expression to filter on partition columns.
        PrimitiveTypeInfo pti = TypeInfoFactory.getPrimitiveTypeInfo(type);
        Converter converter = ObjectInspectorConverters.getConverter(
          TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(TypeInfoFactory.stringTypeInfo),
          TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(pti));
        ExprNodeColumnDesc column = new ExprNodeColumnDesc(pti, key, null, true);
        ExprNodeGenericFuncDesc op = makeBinaryPredicate(
View Full Code Here

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

          + " argument of " + opName + "  is expected to a "
          + "numeric type, but "
          + inputOI.getTypeName() + " is found");
    }

    PrimitiveTypeInfo resultTypeInfo = null;
    PrimitiveTypeInfo inputTypeInfo = inputOI.getTypeInfo();
    if (inputTypeInfo instanceof DecimalTypeInfo) {
      DecimalTypeInfo decTypeInfo = (DecimalTypeInfo) inputTypeInfo;
      resultTypeInfo = TypeInfoFactory.getDecimalTypeInfo(
          decTypeInfo.precision() - decTypeInfo.scale() + 1, 0);
      ObjectInspector decimalOI = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(decTypeInfo);
View Full Code Here

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

          "Please specify either three or four arguments.");
    }

    // Validate the first parameter, which is the expression to compute over. This should be an
    // array of strings type, or an array of arrays of strings.
    PrimitiveTypeInfo pti;
    if (parameters[0].getCategory() != ObjectInspector.Category.LIST) {
      throw new UDFArgumentTypeException(0,
          "Only list type arguments are accepted but "
          + parameters[0].getTypeName() + " was passed as parameter 1.");
    }
    switch (((ListTypeInfo) parameters[0]).getListElementTypeInfo().getCategory()) {
    case PRIMITIVE:
      // Parameter 1 was an array of primitives, so make sure the primitives are strings.
      pti = (PrimitiveTypeInfo) ((ListTypeInfo) parameters[0]).getListElementTypeInfo();
      break;

    case LIST:
      // Parameter 1 was an array of arrays, so make sure that the inner arrays contain
      // primitive strings.
      ListTypeInfo lti = (ListTypeInfo)
                         ((ListTypeInfo) parameters[0]).getListElementTypeInfo();
      pti = (PrimitiveTypeInfo) lti.getListElementTypeInfo();
      break;

    default:
      throw new UDFArgumentTypeException(0,
          "Only arrays of strings or arrays of arrays of strings are accepted but "
          + parameters[0].getTypeName() + " was passed as parameter 1.");
    }
    if(pti.getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.STRING) {
      throw new UDFArgumentTypeException(0,
          "Only array<string> or array<array<string>> is allowed, but "
          + parameters[0].getTypeName() + " was passed as parameter 1.");
    }
View Full Code Here

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

   * @param rightOI TypeInfo instance of the right operand
   * @return
   * @throws UDFArgumentException
   */
  private PrimitiveTypeInfo deriveResultTypeInfo() throws UDFArgumentException {
    PrimitiveTypeInfo left = (PrimitiveTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(leftOI);
    PrimitiveTypeInfo right = (PrimitiveTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(rightOI);
    if (!FunctionRegistry.isNumericType(left) || !FunctionRegistry.isNumericType(right)) {
      List<TypeInfo> argTypeInfos = new ArrayList<TypeInfo>(2);
      argTypeInfos.add(left);
      argTypeInfos.add(right);
      throw new NoMatchingMethodException(this.getClass(), argTypeInfos, null);
View Full Code Here

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

   * Default implementation for getting the approximate type info for the operator result.
   * Divide operator overrides this.
   * @return
   */
  protected PrimitiveTypeInfo deriveResultApproxTypeInfo() {
    PrimitiveTypeInfo left = (PrimitiveTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(leftOI);
    PrimitiveTypeInfo right = (PrimitiveTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(rightOI);

    // string types get converted to double
    if (PrimitiveObjectInspectorUtils.getPrimitiveGrouping(left.getPrimitiveCategory())
            == PrimitiveGrouping.STRING_GROUP) {
      left = TypeInfoFactory.doubleTypeInfo;
    }
    if (PrimitiveObjectInspectorUtils.getPrimitiveGrouping(right.getPrimitiveCategory())
        == PrimitiveGrouping.STRING_GROUP) {
      right = TypeInfoFactory.doubleTypeInfo;
    }   

    // Use type promotion
View Full Code Here

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

   * but divide operator.
   *
   * @return
   */
  protected PrimitiveTypeInfo deriveResultExactTypeInfo() {
    PrimitiveTypeInfo left = (PrimitiveTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(leftOI);
    PrimitiveTypeInfo right = (PrimitiveTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(rightOI);

    // Now we are handling exact types. Base implementation handles type promotion.
    PrimitiveCategory commonCat = FunctionRegistry.getCommonCategory(left, right);
    if (commonCat == PrimitiveCategory.DECIMAL) {
      return deriveResultDecimalTypeInfo();
View Full Code Here

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

          + " argument of " + opName + "  is expected to a "
          + "numeric type, but "
          + inputOI.getTypeName() + " is found");
    }

    PrimitiveTypeInfo resultTypeInfo = deriveResultTypeInfo(inputOI.getTypeInfo());
    resultOI = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(resultTypeInfo);
    converter = ObjectInspectorConverters.getConverter(inputOI, resultOI);
    return resultOI;
  }
View Full Code Here

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

          "Please specify either three or four arguments.");
    }

    // Validate the first parameter, which is the expression to compute over. This should be an
    // array of strings type, or an array of arrays of strings.
    PrimitiveTypeInfo pti;
    if (parameters[0].getCategory() != ObjectInspector.Category.LIST) {
      throw new UDFArgumentTypeException(0,
          "Only list type arguments are accepted but "
          + parameters[0].getTypeName() + " was passed as parameter 1.");
    }
    switch (((ListTypeInfo) parameters[0]).getListElementTypeInfo().getCategory()) {
    case PRIMITIVE:
      // Parameter 1 was an array of primitives, so make sure the primitives are strings.
      pti = (PrimitiveTypeInfo) ((ListTypeInfo) parameters[0]).getListElementTypeInfo();
      break;

    case LIST:
      // Parameter 1 was an array of arrays, so make sure that the inner arrays contain
      // primitive strings.
      ListTypeInfo lti = (ListTypeInfo)
                         ((ListTypeInfo) parameters[0]).getListElementTypeInfo();
      pti = (PrimitiveTypeInfo) lti.getListElementTypeInfo();
      break;

    default:
      throw new UDFArgumentTypeException(0,
          "Only arrays of strings or arrays of arrays of strings are accepted but "
          + parameters[0].getTypeName() + " was passed as parameter 1.");
    }
    if(pti.getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.STRING) {
      throw new UDFArgumentTypeException(0,
          "Only array<string> or array<array<string>> is allowed, but "
          + parameters[0].getTypeName() + " was passed as parameter 1.");
    }
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.