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

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


  @Override
  public StructObjectInspector initialize(ObjectInspector[] args)
      throws UDFArgumentException {
    if (args.length < 2)  {
      throw new UDFArgumentException("STACK() expects at least two arguments.");
    }
    if (!(args[0] instanceof WritableConstantIntObjectInspector)) {
      throw new UDFArgumentException(
          "The first argument to STACK() must be a constant integer (got " +
          args[0].getTypeName() + " instead).");
    }
    numRows =
        ((WritableConstantIntObjectInspector)args[0]).getWritableConstantValue();

    if (numRows == null || numRows.get() < 1) {
      throw new UDFArgumentException(
          "STACK() expects its first argument to be >= 1.");
    }

    // Divide and round up.
    numCols = (args.length - 1 + numRows.get() - 1) / numRows.get();

    for (int jj = 0; jj < numCols; ++jj) {
      returnOIResolvers.add(new ReturnObjectInspectorResolver());
      for (int ii = 0; ii < numRows.get(); ++ii) {
        int index = ii * numCols + jj + 1;
        if (index < args.length &&
            !returnOIResolvers.get(jj).update(args[index])) {
          throw new UDFArgumentException(
              "Argument " + (jj + 1) + "'s type (" +
              args[jj + 1].getTypeName() + ") should be equal to argument " +
              index + "'s type (" + args[index].getTypeName() + ")");
        }
      }
View Full Code Here


          + arguments.length);
    }
    try {
      argumentOI = (PrimitiveObjectInspector) arguments[0];
    } catch (ClassCastException e) {
      throw new UDFArgumentException(
          "The function TIMESTAMP takes only primitive types");
    }

    tc = new TimestampConverter(argumentOI,
        PrimitiveObjectInspectorFactory.writableTimestampObjectInspector);
View Full Code Here

  @Override
  public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {

    if (udfClass == null) {
      throw new UDFArgumentException(
          "The UDF implementation class '" + udfClassName
              + "' is not present in the class path");
    }
    udf = (UDF) ReflectionUtils.newInstance(udfClass, null);
View Full Code Here

  @Override
  public ObjectInspector initialize(ObjectInspector[] arguments)
      throws UDFArgumentException {
    if (arguments.length != 2) {
      throw new UDFArgumentException("Invalid number of arguments.");
    }

    converterArg0 = ObjectInspectorConverters.getConverter(arguments[0],
        PrimitiveObjectInspectorFactory.writableStringObjectInspector);
    converterArg1 = ObjectInspectorConverters.getConverter(arguments[1],
View Full Code Here

    public static ExprNodeDesc getFuncExprNodeDesc(String udfName,
        ExprNodeDesc... children) throws UDFArgumentException {

      FunctionInfo fi = FunctionRegistry.getFunctionInfo(udfName);
      if (fi == null) {
        throw new UDFArgumentException(udfName + " not found.");
      }

      GenericUDF genericUDF = fi.getGenericUDF();
      if (genericUDF == null) {
        throw new UDFArgumentException(udfName
            + " is an aggregation function or a table function.");
      }

      List<ExprNodeDesc> childrenList = new ArrayList<ExprNodeDesc>(children.length);
      childrenList.addAll(Arrays.asList(children));
View Full Code Here

      }
      try {
        Object constantValue = evaluate(argumentValues);
        oi = ObjectInspectorUtils.getConstantObjectInspector(oi, constantValue);
      } catch (HiveException e) {
        throw new UDFArgumentException(e);
      }
    }
    return oi;
  }
View Full Code Here

      argumentOIs[0] = (PrimitiveObjectInspector) arguments[0];
      if (arguments.length > 1) {
        argumentOIs[1] = (PrimitiveObjectInspector) arguments[1];
      }
    } catch (ClassCastException e) {
      throw new UDFArgumentException(
          "The function " + getName() + " takes only primitive types");
    }

    timestampConverter = new TimestampConverter(argumentOIs[0],
        PrimitiveObjectInspectorFactory.writableTimestampObjectInspector);
View Full Code Here

            !TypeInfoUtils.getTypeInfoFromObjectInspector(arguments[1]).equals(
            TypeInfoFactory.stringTypeInfo))
        || (arguments.length > 2 &&
            !TypeInfoUtils.getTypeInfoFromObjectInspector(arguments[2]).equals(
            TypeInfoFactory.stringTypeInfo))) {
      throw new UDFArgumentException("All argument should be string");
    }

    soi_text = (StringObjectInspector) arguments[0];
    if (arguments.length > 1) {
      soi_de1 = (StringObjectInspector) arguments[1];
View Full Code Here

    inputOIs = args;
    numCols = args.length - 1;

    if (numCols < 1) {
      throw new UDFArgumentException("json_tuple() takes at least two arguments: " +
          "the json string and a path expression");
    }

    for (int i = 0; i < args.length; ++i) {
      if (args[i].getCategory() != ObjectInspector.Category.PRIMITIVE ||
          !args[i].getTypeName().equals(Constants.STRING_TYPE_NAME)) {
        throw new UDFArgumentException("json_tuple()'s arguments have to be string type");
      }
    }

    seenErrors = false;
    pathParsed = false;
View Full Code Here

            sb.append(", ");
          }
          sb.append(arguments[i].getTypeName());
        }
        sb.append(")}");
        throw new UDFArgumentException(sb.toString());
      }
    }
    compareOI = conversionHelper.get();

    checkIfInSetConstant();
View Full Code Here

TOP

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

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.