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

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


   
    boolean r = caseOIResolver.update(arguments[0]);
    assert(r);
    for (int i=1; i+1<arguments.length; i+=2) {
      if (!caseOIResolver.update(arguments[i])) {
        throw new UDFArgumentTypeException(i,
            "The expressions after WHEN should have the same type with that after CASE: \""
            + caseOIResolver.get().getTypeName() + "\" is expected but \""
            + arguments[i].getTypeName() + "\" is found");
      }
      if (!returnOIResolver.update(arguments[i+1])) {
        throw new UDFArgumentTypeException(i+1,
            "The expressions after THEN should have the same type: \""
            + returnOIResolver.get().getTypeName() + "\" is expected but \""
            + arguments[i+1].getTypeName() + "\" is found");
      }
    }
    if (arguments.length % 2 == 0) {
      int i = arguments.length - 2;
      if (!returnOIResolver.update(arguments[i+1])) {
        throw new UDFArgumentTypeException(i+1,
            "The expression after ELSE should have the same type as those after THEN: \""
            + returnOIResolver.get().getTypeName() + "\" is expected but \""
            + arguments[i+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.");
    }
   
    if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
      throw new UDFArgumentTypeException(0,
          "Only primitive type arguments are accepted but "
          + parameters[0].getTypeName() + " is passed.");
    }
    switch (((PrimitiveTypeInfo)parameters[0]).getPrimitiveCategory()) {
      case BYTE:
      case SHORT:
      case INT:
      case LONG:
      case FLOAT:
      case DOUBLE:
      case STRING:
        return new GenericUDAFStdSampleEvaluator();
      case BOOLEAN:
      default:
        throw new UDFArgumentTypeException(0,
            "Only numeric or string type arguments are accepted but "
            + parameters[0].getTypeName() + " is passed.");
    }
  }
View Full Code Here

    }

    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 function INSTR is expected to a "
            + Category.PRIMITIVE.toString().toLowerCase()
            + " type, but " + category.toString().toLowerCase() + " is found");
      }
    }
View Full Code Here

    this.argumentOIs = arguments;
   
    returnOIResolver = new GenericUDFUtils.ReturnObjectInspectorResolver();
    for (int i=0; i<arguments.length; i++) {
      if (!returnOIResolver.update(arguments[i])) {
        throw new UDFArgumentTypeException(i,
            "The expressions after COALESCE should all have the same type: \""
            + returnOIResolver.get().getTypeName() + "\" is expected but \""
            + arguments[i].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.");
    }
   
    if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
      throw new UDFArgumentTypeException(0,
          "Only primitive type arguments are accepted but " + parameters[0].getTypeName() + " is passed.");
    }
    switch (((PrimitiveTypeInfo)parameters[0]).getPrimitiveCategory()) {
      case BYTE:
      case SHORT:
      case INT:
      case LONG:
      case FLOAT:
      case DOUBLE:
      case STRING:
        return new GenericUDAFAverageEvaluator();
      case BOOLEAN:
      default:
        throw new UDFArgumentTypeException(0,
            "Only numeric or string type arguments are accepted but " + parameters[0].getTypeName() + " is passed.");
    }
  }
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.");
    }
   
    if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
      throw new UDFArgumentTypeException(0,
          "Only primitive type arguments are accepted but "
          + parameters[0].getTypeName() + " is passed.");
    }
    switch (((PrimitiveTypeInfo)parameters[0]).getPrimitiveCategory()) {
      case BYTE:
      case SHORT:
      case INT:
      case LONG:
      case FLOAT:
      case DOUBLE:
      case STRING:
        return new GenericUDAFStdEvaluator();
      case BOOLEAN:
      default:
        throw new UDFArgumentTypeException(0,
            "Only numeric or string type arguments are accepted but "
            + parameters[0].getTypeName() + " is passed.");
    }
  }
View Full Code Here

    }

    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 function LOCATE is expected to a "
            + Category.PRIMITIVE.toString().toLowerCase()
            + " type, but " + category.toString().toLowerCase() + " is found");
      }
    }
View Full Code Here

    } else if (arguments[0] instanceof ListObjectInspector) {
      // index into a list
      listOI = (ListObjectInspector)arguments[0];
      mapOI = null;
    } else {
      throw new UDFArgumentTypeException(0,
          "\"" + Category.MAP.toString().toLowerCase()
          + "\" or \"" + Category.LIST.toString().toLowerCase()
          + "\" is expected at function INDEX, but \""
          + arguments[0].getTypeName() + "\" is found");
    }
   
    // index has to be a primitive
    if (arguments[1] instanceof PrimitiveObjectInspector) {
      indexOI = (PrimitiveObjectInspector) arguments[1];
    } else {
      throw new UDFArgumentTypeException(1,
          "Primitive Type is expected but " + arguments[1].getTypeName()
          + "\" is found");
    }

    if (mapOI != null) {
View Full Code Here

      PrimitiveObjectInspector poi = ((PrimitiveObjectInspector)arguments[0]);
      conditionTypeIsOk = (poi.getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.BOOLEAN
                           || poi.getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.VOID);
    }
    if (!conditionTypeIsOk) {
      throw new UDFArgumentTypeException(0,
          "The first argument of function IF should be \"" + Constants.BOOLEAN_TYPE_NAME
          + "\", but \"" + arguments[0].getTypeName() + "\" is found");
    }

    if( !(returnOIResolver.update(arguments[1])
         && returnOIResolver.update(arguments[2])) ) {
      throw new UDFArgumentTypeException(2,
          "The second and the third arguments of function IF should have the same type, " +
          "but they are different: \"" + arguments[1].getTypeName()
          + "\" and \"" + arguments[2].getTypeName() + "\"");
    }
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.");
    }
   
    if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
      throw new UDFArgumentTypeException(0,
          "Only primitive type arguments are accepted but "
          + parameters[0].getTypeName() + " is passed.");
    }
    switch (((PrimitiveTypeInfo)parameters[0]).getPrimitiveCategory()) {
      case BYTE:
      case SHORT:
      case INT:
      case LONG:
      case FLOAT:
      case DOUBLE:
      case STRING:
        return new GenericUDAFVarianceEvaluator();
      case BOOLEAN:
      default:
        throw new UDFArgumentTypeException(0,
            "Only numeric or string type arguments are accepted but "
            + parameters[0].getTypeName() + " is passed.");
    }
  }
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.