Package org.apache.tajo.engine.eval

Examples of org.apache.tajo.engine.eval.FieldEval


        for (int i = 0; i < targetTableSchema.getColumnNum(); i++) {
          Column column = targetTableSchema.getColumn(i);
          for (int j = 0; j < targetColumnIds.length; j++) {
            if (targetColumnIds[j] == i) {
              Column outputColumn = subQueryOutSchema.getColumn(j);
              targets[i] = new Target(new FieldEval(outputColumn), column.getColumnName());
              matched = true;
              break;
            }
          }
          if (!matched) {
View Full Code Here


    this.unresolvedTargets[id] = target;

    EvalNode evalNode = target.getEvalTree();
    if (evalNode.getType() == EvalType.FIELD) {
      if (target.hasAlias()) {
        FieldEval fieldEval = (FieldEval) evalNode;
        targetColumnToId.put(fieldEval.getColumnRef(), id);
      }
    }
    targetColumnToId.put(target.getColumnSchema(), id);
  }
View Full Code Here

        continue;
      }

      if (!exclude.contains(i) && resolvedFlags[i]) { // if this target was evaluated, it becomes a column target.
        Column col = getResolvedTargetToColumn(i);
        updated[i] = new Target(new FieldEval(col));
      } else {
        try {
          updated[i] = (Target) targets[i].clone();
        } catch (CloneNotSupportedException e) {
          throw new PlanningException(e);
View Full Code Here

        continue;
      }

      if (resolvedFlags[i]) { // if this target was evaluated, it becomes a column target.
        Column col = getResolvedTargetToColumn(i);
        updated[i] = new Target(new FieldEval(col));
      } else {
        try {
          updated[i] = (Target) targets[i].clone();
        } catch (CloneNotSupportedException e) {
          throw new PlanningException(e);
View Full Code Here

        TupleUtil.buildTupleFromPartitionPath(columnPartitionSchema, fileFragments.get(0).getPath(), false);

    // Targets or search conditions may contain column references.
    // However, actual values absent in tuples. So, Replace all column references by constant datum.
    for (Column column : columnPartitionSchema.toArray()) {
      FieldEval targetExpr = new FieldEval(column);
      Datum datum = targetExpr.eval(columnPartitionSchema, partitionRow);
      ConstEval constExpr = new ConstEval(datum);

      for (Target target : plan.getTargets()) {
        if (target.getEvalTree().equals(targetExpr)) {
          if (!target.hasAlias()) {
View Full Code Here

          rewritten.firstStageEvals[0] = createCountRowFunction(function.getArgs());
        } else {
          rewritten.firstStageEvals[0] = createCountFunction(function.getArgs());
        }
        String referenceName = plan.generateUniqueColumnName(rewritten.firstStageEvals[0]);
        FieldEval fieldEval = new FieldEval(referenceName, rewritten.firstStageEvals[0].getValueType());
        rewritten.firstStageTargets[0] = new Target(fieldEval);
        rewritten.secondStageEvals = createSumFunction(new EvalNode[] {fieldEval});
      } else if (function.getName().equalsIgnoreCase("sum")) {
        rewritten = new RewrittenFunctions(1);

        rewritten.firstStageEvals[0] = createSumFunction(function.getArgs());
        String referenceName = plan.generateUniqueColumnName(rewritten.firstStageEvals[0]);
        FieldEval fieldEval = new FieldEval(referenceName, rewritten.firstStageEvals[0].getValueType());
        rewritten.firstStageTargets[0] = new Target(fieldEval);
        rewritten.secondStageEvals = createSumFunction(new EvalNode[] {fieldEval});

      } else if (function.getName().equals("max")) {
        rewritten = new RewrittenFunctions(1);

        rewritten.firstStageEvals[0] = createMaxFunction(function.getArgs());
        String referenceName = plan.generateUniqueColumnName(rewritten.firstStageEvals[0]);
        FieldEval fieldEval = new FieldEval(referenceName, rewritten.firstStageEvals[0].getValueType());
        rewritten.firstStageTargets[0] = new Target(fieldEval);
        rewritten.secondStageEvals = createMaxFunction(new EvalNode[]{fieldEval});

      } else if (function.getName().equals("min")) {

        rewritten = new RewrittenFunctions(1);

        rewritten.firstStageEvals[0] = createMinFunction(function.getArgs());
        String referenceName = plan.generateUniqueColumnName(rewritten.firstStageEvals[0]);
        FieldEval fieldEval = new FieldEval(referenceName, rewritten.firstStageEvals[0].getValueType());
        rewritten.firstStageTargets[0] = new Target(fieldEval);
        rewritten.secondStageEvals = createMinFunction(new EvalNode[]{fieldEval});

      } else {
        throw new PlanningException("Cannot support a mix of other functions");
View Full Code Here

    int firstStageGroupingKeyNum = firstStageGroupingColumns.size();

    int i = 0;
    Target [] firstStageTargets = new Target[firstStageGroupingKeyNum + firstStageAggFunctionNum];
    for (Column column : firstStageGroupingColumns) {
      Target target = new Target(new FieldEval(column));
      firstStageTargets[i++] = target;
    }
    for (Target target : firstPhaseEvalNodeTargets) {
      firstStageTargets[i++] = target;
    }
View Full Code Here

          throw new RuntimeException(e);
        }

        firstPhaseEvals[i].setFirstPhase();
        firstPhaseEvalNames[i] = plan.generateUniqueColumnName(firstPhaseEvals[i]);
        FieldEval param = new FieldEval(firstPhaseEvalNames[i], firstPhaseEvals[i].getValueType());
        secondPhaseEvals[i].setArgs(new EvalNode[] {param});
      }

      secondPhaseGroupBy.setAggFunctions(secondPhaseEvals);
      firstPhaseGroupBy.setAggFunctions(firstPhaseEvals);
View Full Code Here

      // If the expression is already evaluated, it should use the FieldEval to access a field value.
      // But, if this reference name is not primary name, it cannot use the reference name.
      // It changes the given reference name to the primary name.
      if (isEvaluated(normalized) && !isPrimaryName(refId, referenceName)) {
        return new Target(new FieldEval(getPrimaryName(refId),evalNode.getValueType()), referenceName);
      }

      EvalNode referredEval;
      if (evalNode.getType() == EvalType.CONST) {
        referredEval = evalNode;
      } else {
        referredEval = new FieldEval(idToNamesMap.get(refId).get(0), evalNode.getValueType());
      }
      return new Target(referredEval, referenceName);

    } else {
      if (idToEvalMap.containsKey(refId)) {
View Full Code Here

TOP

Related Classes of org.apache.tajo.engine.eval.FieldEval

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.