Package org.apache.hadoop.hive.ql.exec

Examples of org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException


    }

    for (int i = 0; i < 3; i++) {
      if (arguments[i].getTypeName() != serdeConstants.STRING_TYPE_NAME
          && arguments[i].getTypeName() != serdeConstants.VOID_TYPE_NAME) {
        throw new UDFArgumentTypeException(i, "The " + getOrdinal(i + 1)
            + " argument of function TRANSLATE is expected to \""
            + serdeConstants.STRING_TYPE_NAME + "\", but \""
            + arguments[i].getTypeName() + "\" is found");
      }
    }
View Full Code Here


  @Override
  public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo info)
    throws SemanticException {
    ObjectInspector[] inspectors = info.getParameterObjectInspectors();
    if (inspectors.length != 1) {
      throw new UDFArgumentTypeException(inspectors.length - 1,
          "Exactly one argument is expected.");
    }

    if (inspectors[0].getCategory() != ObjectInspector.Category.LIST) {
      throw new UDFArgumentTypeException(0, "Argument should be a list type");
    }

    ListObjectInspector listOI = (ListObjectInspector) inspectors[0];
    ObjectInspector elementOI = listOI.getListElementObjectInspector();

    if (elementOI.getCategory() != ObjectInspector.Category.PRIMITIVE) {
      throw new UDFArgumentTypeException(0,
          "Only primitive type arguments are accepted but "
          + elementOI.getTypeName() + " is passed.");
    }
    PrimitiveObjectInspector.PrimitiveCategory pcat =
        ((PrimitiveObjectInspector)elementOI).getPrimitiveCategory();
View Full Code Here

          "The function evaluate_npe(string)"
            + "needs only one argument.");
    }

    if (!arguments[0].getTypeName().equals(serdeConstants.STRING_TYPE_NAME)) {
      throw new UDFArgumentTypeException(0,
        "Argument 1 of function evaluate_npe must be \""
        + serdeConstants.STRING_TYPE_NAME + "but \""
        + arguments[0].getTypeName() + "\" was found.");
    }
View Full Code Here

    ArrayList<String> fname = new ArrayList<String>(numFields / 2);
    ArrayList<ObjectInspector> retOIs = new ArrayList<ObjectInspector>(numFields / 2);
    for (int f = 0; f < numFields; f+=2) {
      if (!(arguments[f] instanceof WritableConstantStringObjectInspector)) {
        throw new UDFArgumentTypeException(f, "Even arguments" +
            " to NAMED_STRUCT must be a constant STRING." + arguments[f].toString());
      }
      WritableConstantStringObjectInspector constantOI =
        (WritableConstantStringObjectInspector)arguments[f];
      fname.add(constantOI.getWritableConstantValue().toString());
View Full Code Here

        if(((ListObjectInspector)(arguments[0])).getListElementObjectInspector()
          .getCategory().equals(Category.PRIMITIVE)) {
          break;
        }
      default:
        throw new UDFArgumentTypeException(0, "Argument 1"
          + " of function SORT_ARRAY must be " + serdeConstants.LIST_TYPE_NAME
          + "<" + Category.PRIMITIVE + ">, but " + arguments[0].getTypeName()
          + " was found.");
    }
View Full Code Here

    parameterTypes = new PrimitiveTypeEntry[length];
    parameterClasses = new Class[length];
    parameterJavaValues = new Object[length];
    for (int i = 0; i < length; i++) {
      if (arguments[i + start].getCategory() != ObjectInspector.Category.PRIMITIVE) {
        throw new UDFArgumentTypeException(i,
            "The parameters of GenericUDFReflect(class,method[,arg1[,arg2]...])"
            + " must be primitive (int, double, string, etc).");
      }
      parameterOIs[i] = (PrimitiveObjectInspector)arguments[i + start];
      parameterTypes[i] = PrimitiveObjectInspectorUtils.getTypeEntryFromPrimitiveCategory(
View Full Code Here

    }

    if (arguments[0].getCategory().equals(Category.LIST)) {
      b1OI = (ListObjectInspector) arguments[0];
    } else {
        throw new UDFArgumentTypeException(0, "\""
          + Category.LIST.toString().toLowerCase()
          + "\" is expected at function " + name + ", but \""
          + arguments[0].getTypeName() + "\" is found");
    }

    if (!arguments[1].getCategory().equals(Category.LIST)) {
        throw new UDFArgumentTypeException(1, "\""
          + Category.LIST.toString().toLowerCase()
          + "\" is expected at function " + name + ", but \""
          + arguments[1].getTypeName() + "\" is found");

    }
View Full Code Here

  @Override
  public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters)
    throws SemanticException {
    if (parameters.length != 1) {
      throw new UDFArgumentTypeException(parameters.length - 1,
          "Exactly one argument is expected.");
    }
    ObjectInspector oi = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(parameters[0]);
    if (!ObjectInspectorUtils.compareSupported(oi)) {
      throw new UDFArgumentTypeException(parameters.length - 1,
          "Cannot support comparison of map<> type or complex type containing map<>.");
    }
    return new GenericUDAFMaxEvaluator();
  }
View Full Code Here

    argumentOIs = arguments;

    for (int i = 0; i < arguments.length; i++) {
      Category category = arguments[i].getCategory();
      if (category != Category.PRIMITIVE) {
        throw new UDFArgumentTypeException(i, "The "
            + GenericUDFUtils.getOrdinal(i + 1)
            + " argument of " + opName + "  is expected to a "
            + Category.PRIMITIVE.toString().toLowerCase() + " type, but "
            + category.toString().toLowerCase() + " is found");
      }
View Full Code Here

      throw new UDFArgumentLengthException("_FUNC_ expects exactly 3 arguments");
    }

    for (int i = 0; i < arguments.length; i++) {
      if (arguments[i].getCategory() != Category.PRIMITIVE) {
        throw new UDFArgumentTypeException(i,
            "A string argument was expected but an argument of type " + arguments[i].getTypeName()
                + " was given.");

      }

      // Now that we have made sure that the argument is of primitive type, we can get the primitive
      // category
      PrimitiveCategory primitiveCategory = ((PrimitiveObjectInspector) arguments[i])
          .getPrimitiveCategory();

      if (primitiveCategory != PrimitiveCategory.STRING
          && primitiveCategory != PrimitiveCategory.VOID) {
        throw new UDFArgumentTypeException(i,
            "A string argument was expected but an argument of type " + arguments[i].getTypeName()
                + " was given.");

      }
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException

Copyright © 2018 www.massapicom. 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.