Example #1
0
    /*
     * validate and setup resultExprStr
     */
    private void validateAndSetupResultExprStr(
        MatchPath evaluator, List<PTFExpressionDef> args, int argsNum) throws SemanticException {
      PTFExpressionDef resultExprArg = args.get(argsNum - 1);
      ObjectInspector resultExprArgOI = resultExprArg.getOI();

      if (!ObjectInspectorUtils.isConstantObjectInspector(resultExprArgOI)
          || (resultExprArgOI.getCategory() != ObjectInspector.Category.PRIMITIVE)
          || ((PrimitiveObjectInspector) resultExprArgOI).getPrimitiveCategory()
              != PrimitiveObjectInspector.PrimitiveCategory.STRING) {
        throwErrorWithSignature("Currently the result Expr parameter must be a Constant String.");
      }

      evaluator.resultExprStr =
          ((ConstantObjectInspector) resultExprArgOI).getWritableConstantValue().toString();
    }