Package org.eigenbase.rex

Examples of org.eigenbase.rex.RexCall


      return -1;
    }

    private boolean isAlwaysTrue(RexNode predicate) {
      if (predicate instanceof RexCall) {
        RexCall c = (RexCall) predicate;
        if (c.getOperator().getKind() == SqlKind.EQUALS) {
          int lPos = pos(c.getOperands().get(0));
          int rPos = pos(c.getOperands().get(1));
          return lPos != -1 && lPos == rPos;
        }
      }
      return predicate.isAlwaysTrue();
    }
View Full Code Here


    boolean rewrite = false;

    for (RexNode rex : project.getChildExps()) {
      RexNode newExpr = rex;
      if (rex instanceof RexCall) {
        RexCall function = (RexCall) rex;
        String functionName = function.getOperator().getName();
        int nArgs = function.getOperands().size();

        // check if its a convert_from or convert_to function
        if (functionName.equalsIgnoreCase("convert_from") || functionName.equalsIgnoreCase("convert_to")) {
          assert nArgs == 2 && function.getOperands().get(1) instanceof RexLiteral;
          String literal = ((NlsString) (((RexLiteral) function.getOperands().get(1)).getValue())).getValue();
          RexBuilder builder = new RexBuilder(factory);

          // construct the new function name based on the input argument
          String newFunctionName = functionName + literal;

          // Look up the new function name in the drill operator table
          List<SqlOperator> operatorList = table.getSqlOperator(newFunctionName);
          assert operatorList.size() > 0;
          SqlFunction newFunction = null;

          // Find the SqlFunction with the correct args
          for (SqlOperator op : operatorList) {
            if (op.getOperandTypeChecker().getOperandCountRange().isValidCount(nArgs - 1)) {
              newFunction = (SqlFunction) op;
              break;
            }
          }
          assert newFunction != null;

          // create the new expression to be used in the rewritten project
          newExpr = builder.makeCall(newFunction, function.getOperands().subList(0, 1));
          rewrite = true;
        }
      }
      exprList.add(newExpr);
    }
View Full Code Here

      ListIterator<RexNode> filterIter = joinFilters.listIterator();
      while (filterIter.hasNext()) {
        RexNode exp = filterIter.next();

        if (exp instanceof RexCall) {
          RexCall c = (RexCall) exp;
          boolean validHiveJoinFilter = false;

          if ((c.getOperator().getKind() == SqlKind.EQUALS)) {
            validHiveJoinFilter = true;
            for (RexNode rn : c.getOperands()) {
              // NOTE: Hive dis-allows projections from both left & right side
              // of join condition. Example: Hive disallows
              // (r1.x +r2.x)=(r1.y+r2.y) on join condition.
              if (filterRefersToBothSidesOfJoin(rn, join)) {
                validHiveJoinFilter = false;
                break;
              }
            }
          } else if ((c.getOperator().getKind() == SqlKind.LESS_THAN)
              || (c.getOperator().getKind() == SqlKind.GREATER_THAN)
              || (c.getOperator().getKind() == SqlKind.LESS_THAN_OR_EQUAL)
              || (c.getOperator().getKind() == SqlKind.GREATER_THAN_OR_EQUAL)) {
            validHiveJoinFilter = true;
            // NOTE: Hive dis-allows projections from both left & right side of
            // join in in equality condition. Example: Hive disallows (r1.x <
            // r2.x) on join condition.
            if (filterRefersToBothSidesOfJoin(c, join)) {
View Full Code Here

    // TODO: Cast Function in Optiq have a bug where it infertype on cast throws
    // an exception
    if (flattenExpr && (expr instanceof RexCall)
        && !(((RexCall) expr).getOperator() instanceof SqlCastFunction)) {
      RexCall call = (RexCall) expr;
      expr = cluster.getRexBuilder().makeCall(retType, call.getOperator(),
          RexUtil.flatten(call.getOperands(), call.getOperator()));
    }

    return expr;
  }
View Full Code Here

    int i = 0;
    RexNode flatttenExpr = null;
    for (RexNode rex : project.getChildExps()) {
      RexNode newExpr = rex;
      if (rex instanceof RexCall) {
        RexCall function = (RexCall) rex;
        String functionName = function.getOperator().getName();
        int nArgs = function.getOperands().size();

        if (functionName.equalsIgnoreCase("flatten") ) {
          rewrite = true;
          if (function.getOperands().size() != 1) {
            throw new RelConversionException("Flatten expression expects a single input.");
          }
          newExpr = function.getOperands().get(0);
          RexBuilder builder = new RexBuilder(factory);
          flatttenExpr = builder.makeInputRef( new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory), i);
        }
      }
      relDataTypes.add(project.getRowType().getFieldList().get(i));
View Full Code Here

    boolean rewrite = false;

    for (RexNode rex : project.getChildExps()) {
      RexNode newExpr = rex;
      if (rex instanceof RexCall) {
        RexCall function = (RexCall) rex;
        String functionName = function.getOperator().getName();
        int nArgs = function.getOperands().size();

        // check if its a convert_from or convert_to function
        if (functionName.equalsIgnoreCase("convert_from") || functionName.equalsIgnoreCase("convert_to")) {
          assert nArgs == 2 && function.getOperands().get(1) instanceof RexLiteral;
          String literal = ((NlsString) (((RexLiteral) function.getOperands().get(1)).getValue())).getValue();
          RexBuilder builder = new RexBuilder(factory);

          // construct the new function name based on the input argument
          String newFunctionName = functionName + literal;

          // Look up the new function name in the drill operator table
          List<SqlOperator> operatorList = table.getSqlOperator(newFunctionName);
          assert operatorList.size() > 0;
          SqlFunction newFunction = null;

          // Find the SqlFunction with the correct args
          for (SqlOperator op : operatorList) {
            if (op.getOperandTypeChecker().getOperandCountRange().isValidCount(nArgs - 1)) {
              newFunction = (SqlFunction) op;
              break;
            }
          }
          assert newFunction != null;

          // create the new expression to be used in the rewritten project
          newExpr = builder.makeCall(newFunction, function.getOperands().subList(0, 1));
          rewrite = true;
        }
      }
      exprList.add(newExpr);
    }
View Full Code Here

      return -1;
    }

    private boolean isAlwaysTrue(RexNode predicate) {
      if (predicate instanceof RexCall) {
        RexCall c = (RexCall) predicate;
        if (c.getOperator().getKind() == SqlKind.EQUALS) {
          int lPos = pos(c.getOperands().get(0));
          int rPos = pos(c.getOperands().get(1));
          return lPos != -1 && lPos == rPos;
        }
      }
      return predicate.isAlwaysTrue();
    }
View Full Code Here

TOP

Related Classes of org.eigenbase.rex.RexCall

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.