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

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


        case DATE_GROUP:
        case STRING_GROUP:
        case VOID_GROUP:
          break;
        default:
          throw new UDFArgumentException(
              "CAST as DATE only allows date,string, or timestamp types");
      }
    } catch (ClassCastException e) {
      throw new UDFArgumentException(
          "The function CAST as DATE takes only primitive types");
    }

    dc = new DateConverter(argumentOI,
        PrimitiveObjectInspectorFactory.writableDateObjectInspector);
View Full Code Here


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

    if (args.length != 1) {
      throw new UDFArgumentException("posexplode() takes only one argument");
    }

    if (args[0].getCategory() != ObjectInspector.Category.LIST) {
      throw new UDFArgumentException("posexplode() takes an array as a parameter");
    }
    listOI = (ListObjectInspector) args[0];

    ArrayList<String> fieldNames = new ArrayList<String>();
    ArrayList<ObjectInspector> fieldOIs = new ArrayList<ObjectInspector>();
View Full Code Here

      throw new UDFArgumentLengthException(
          "UPPER requires 1 argument, got " + arguments.length);
    }

    if (arguments[0].getCategory() != Category.PRIMITIVE) {
      throw new UDFArgumentException(
          "UPPER only takes primitive types, got " + argumentOI.getTypeName());
    }
    argumentOI = (PrimitiveObjectInspector) arguments[0];

    stringConverter = new PrimitiveObjectInspectorConverter.StringConverter(argumentOI);
View Full Code Here

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

    if (arguments.length != 2) {
      throw new UDFArgumentException(
          opName + " requires two arguments.");
    }

    argumentOIs = arguments;
View Full Code Here

  }

  @Override
  public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    if (arguments.length != 1) {
      throw new UDFArgumentException("VARCHAR cast requires a value argument");
    }
    try {
      argumentOI = (PrimitiveObjectInspector) arguments[0];
    } catch (ClassCastException e) {
      throw new UDFArgumentException(
          "The function VARCHAR takes only primitive types");
    }

    // Check if this UDF has been provided with type params for the output varchar type
    SettableHiveVarcharObjectInspector outputOI;
View Full Code Here

  @Override
  public ObjectInspector initialize(ObjectInspector[] arguments)
      throws UDFArgumentException {
    if (arguments.length < 2) {
      throw new UDFArgumentException(
          "The function FIELD(str, str1, str2, ...) needs at least two arguments.");
    }

    argumentOIs = arguments;
View Full Code Here

      dateWritableConverter = ObjectInspectorConverters.getConverter(
        (PrimitiveObjectInspector) arguments[0],
        PrimitiveObjectInspectorFactory.writableDateObjectInspector);
      break;
    default:
      throw new UDFArgumentException(
        " DATE_ADD() only takes STRING/TIMESTAMP/DATEWRITABLE types as first argument, got "
        + inputType1);
    }

    inputType2 = ((PrimitiveObjectInspector) arguments[1]).getPrimitiveCategory();
    if (inputType2 != PrimitiveCategory.INT) {
      throw new UDFArgumentException(
        " DATE_ADD() only takes INT types as second  argument, got " + inputType2);
    }
    intWritableConverter = ObjectInspectorConverters.getConverter(
      (PrimitiveObjectInspector) arguments[1],
      PrimitiveObjectInspectorFactory.writableIntObjectInspector);
View Full Code Here

      DateWritable dw = (DateWritable) dateWritableConverter.convert(arguments[0].get());
      calendar.setTime(dw.get());
      calendar.add(Calendar.DAY_OF_MONTH, toBeAdded.get());
      break;
    default:
      throw new UDFArgumentException(
        "DATE_ADD() only takes STRING/TIMESTAMP/DATEWRITABLE types, got " + inputType1);
    }
    Date newDate = calendar.getTime();
    output.set(formatter.format(newDate));
    return output;
View Full Code Here

      throw new UDFArgumentLengthException(
          "ABS() requires 1 argument, got " + arguments.length);
    }

    if (arguments[0].getCategory() != Category.PRIMITIVE) {
      throw new UDFArgumentException(
          "ABS only takes primitive types, got " + arguments[0].getTypeName());
    }
    argumentOI = (PrimitiveObjectInspector) arguments[0];

    inputType = argumentOI.getPrimitiveCategory();
    ObjectInspector outputOI = null;
    switch (inputType) {
    case SHORT:
    case BYTE:
    case INT:
      inputConverter = ObjectInspectorConverters.getConverter(arguments[0],
          PrimitiveObjectInspectorFactory.writableIntObjectInspector);
      outputOI = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
      break;
    case LONG:
      inputConverter = ObjectInspectorConverters.getConverter(arguments[0],
          PrimitiveObjectInspectorFactory.writableLongObjectInspector);
      outputOI = PrimitiveObjectInspectorFactory.writableLongObjectInspector;
      break;
    case FLOAT:
    case STRING:
    case DOUBLE:
      inputConverter = ObjectInspectorConverters.getConverter(arguments[0],
          PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
      outputOI = PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
      break;
    case DECIMAL:
      inputConverter = ObjectInspectorConverters.getConverter(arguments[0],
          PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector);
      outputOI = PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector;
      break;
    default:
      throw new UDFArgumentException(
          "ABS only takes SHORT/BYTE/INT/LONG/DOUBLE/FLOAT/STRING/DECIMAL types, got " + inputType);
    }
    return outputOI;
  }
View Full Code Here

          PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector
              .create(HiveDecimal.ZERO),
          PrimitiveObjectInspectorUtils.getHiveDecimal(valObject,
              argumentOI).abs());
    default:
      throw new UDFArgumentException(
          "ABS only takes SHORT/BYTE/INT/LONG/DOUBLE/FLOAT/STRING/DECIMAL types, got " + inputType);
    }
  }
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.