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

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


    returnOIResolver = new GenericUDFUtils.ReturnObjectInspectorResolver(true);

    for(int i=0; i<arguments.length; i++) {
      if(!returnOIResolver.update(arguments[i])) {
        throw new UDFArgumentTypeException(i, "Argument type \"" + arguments[i].getTypeName() +
            "\" is different from preceding arguments. " +
            "Previous type was \"" + arguments[i-1].getTypeName() + "\"");
      }
    }
   
View Full Code Here


    for(int i=0; i<arguments.length; i++) {
      if(i%2==0) {
        // Keys
        if (!(arguments[i] instanceof PrimitiveObjectInspector)) {
          throw new UDFArgumentTypeException(1,
              "Primitive Type is expected but " + arguments[i].getTypeName()
              + "\" is found");
        }
        if(!keyOIResolver.update(arguments[i])) {
          throw new UDFArgumentTypeException(i, "Key type \"" + arguments[i].getTypeName() +
              "\" is different from preceding key types. " +
              "Previous key type was \"" + arguments[i-2].getTypeName() + "\"");
        }
      } else {
        // Values
        if(!valueOIResolver.update(arguments[i])) {
          throw new UDFArgumentTypeException(i, "Value type \"" + arguments[i].getTypeName() +
              "\" is different from preceding value types. " +
              "Previous value type was \"" + arguments[i-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:
        return new GenericUDAFSumLong();
      case FLOAT:
      case DOUBLE:
      case STRING:
        return new GenericUDAFSumDouble();
      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 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

    }
   
    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 FIELD is expected to a "
            + Category.PRIMITIVE.toString().toLowerCase()
            + " type, but " + category.toString().toLowerCase() + " 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 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

    }

    for (int i = 0; i < arguments.length; i++) {
      if(arguments[i].getTypeName() != Constants.STRING_TYPE_NAME
         && arguments[i].getTypeName() != Constants.VOID_TYPE_NAME) {
        throw new UDFArgumentTypeException(i,
                                           "Argument " + (i +1 + " of function CONCAT_WS must be \"" + Constants.STRING_TYPE_NAME
                                           + "\", but \"" + arguments[i].getTypeName() + "\" was found.");
      }
    }
View Full Code Here

    for (int i=0;i<4;i++){
      if ( arguments[i].getCategory() == ObjectInspector.Category.PRIMITIVE) {
        PrimitiveObjectInspector poi = ((PrimitiveObjectInspector)arguments[i]);
       
        if (! (poi.getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.STRING)){
          throw new UDFArgumentTypeException(i,
            "The argument of function  should be \"" + Constants.STRING_TYPE_NAME
            + "\", but \"" + arguments[i].getTypeName() + "\" is found");
        }
      }
    }
    for (int i=4;i<arguments.length;i++){
      if ( arguments[i].getCategory() != ObjectInspector.Category.PRIMITIVE) {
        throw new UDFArgumentTypeException(i,
            "The argument of function should be primative" +
             ", but \"" + arguments[i].getTypeName() + "\" is found");
      }
    }
   
View Full Code Here

  @Override
  public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters)
      throws SemanticException {
    if (parameters.length != 2 ) {
      throw new UDFArgumentTypeException(parameters.length - 1,
          "Exactly two arguments are 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 BOOLEAN:
      return new GenericUDAFBooleanStatsEvaluator();
    case BYTE:
    case SHORT:
    case INT:
    case LONG:
    case TIMESTAMP:
      return new GenericUDAFLongStatsEvaluator();
    case FLOAT:
    case DOUBLE:
      return new GenericUDAFDoubleStatsEvaluator();
    case STRING:
      return new GenericUDAFStringStatsEvaluator();
    case BINARY:
      return new GenericUDAFBinaryStatsEvaluator();
    default:
      throw new UDFArgumentTypeException(0,
          "Only integer/long/timestamp/float/double/string/binary/boolean type argument " +
          "is accepted but "
          + parameters[0].getTypeName() + " is passed.");
    }
  }
View Full Code Here

    Category category = arguments[0].getCategory();
    String typeName = arguments[0].getTypeName();
    if (category != Category.MAP
        && category != Category.LIST
        && !typeName.equals(Constants.VOID_TYPE_NAME)) {
      throw new UDFArgumentTypeException(0 ,
          "\"" + Category.MAP.toString().toLowerCase()
          + "\" or \"" + Category.LIST.toString().toLowerCase()  + "\" is expected at function SIZE, "
          + "but \"" + arguments[0].getTypeName() + "\" is found");
    }
   
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.