/** * Adds a project expression to the program at a given position. * * <p>The expression specified in terms of the input fields. If not, call * {@link #registerOutput(RexNode)} first. * * @param at Position in project list to add expression * @param expr Expression to add * @param name Name of field in output row type; if null, a unique name will * be generated when the program is created * @return the ref created */ public RexLocalRef addProject(int at, RexNode expr, String name) { final RexLocalRef ref = registerInput(expr); projectRefList.add(at, ref); projectNameList.add(at, name); return ref; }
/** * Adds a project expression to the program at a given position. * * <p>The expression specified in terms of the input fields. If not, call * {@link #registerOutput(RexNode)} first. * * @param at Position in project list to add expression * @param expr Expression to add * @param name Name of field in output row type; if null, a unique name will * be generated when the program is created * @return the ref created */ public RexLocalRef addProject(int at, RexNode expr, String name) { final RexLocalRef ref = registerInput(expr); projectRefList.add(at, ref); projectNameList.add(at, name); return ref; }
/** * Sets the condition of the program. * * <p>The expression must be specified in terms of the input fields. If * not, call {@link #registerOutput(RexNode)} first.</p> */ public void addCondition(RexNode expr) { assert expr != null; if (conditionRef == null) { conditionRef = registerInput(expr); } else { // AND the new condition with the existing condition. // If the new condition is identical to the existing condition, skip it. RexLocalRef ref = registerInput(expr); if (!ref.equals(conditionRef)) { conditionRef = registerInput( rexBuilder.makeCall( SqlStdOperatorTable.AND, conditionRef, ref)); } } }
/** * Sets the condition of the program. * * <p>The expression must be specified in terms of the input fields. If * not, call {@link #registerOutput(RexNode)} first.</p> */ public void addCondition(RexNode expr) { assert expr != null; if (conditionRef == null) { conditionRef = registerInput(expr); } else { // AND the new condition with the existing condition. // If the new condition is identical to the existing condition, skip it. RexLocalRef ref = registerInput(expr); if (!ref.equals(conditionRef)) { conditionRef = registerInput( rexBuilder.makeCall( SqlStdOperatorTable.AND, conditionRef, ref)); } } }
/** * Adds a project expression to the program. * * <p>The expression specified in terms of the input fields. If not, call * {@link #registerOutput(RexNode)} first. * * @param expr Expression to add * @param name Name of field in output row type; if null, a unique name will * be generated when the program is created * @return the ref created */ public RexLocalRef addProject(RexNode expr, String name) { final RexLocalRef ref = registerInput(expr); return addProject(ref.getIndex(), name); }
/** * Adds a project expression to the program. * * <p>The expression specified in terms of the input fields. If not, call * {@link #registerOutput(RexNode)} first. * * @param expr Expression to add * @param name Name of field in output row type; if null, a unique name will * be generated when the program is created * @return the ref created */ public RexLocalRef addProject(RexNode expr, String name) { final RexLocalRef ref = registerInput(expr); return addProject(ref.getIndex(), name); }
private List<RexLocalRef> registerProjectsAndCondition(RexProgram program) { final List<RexNode> exprList = program.getExprList(); final List<RexLocalRef> projectRefList = new ArrayList<>(); final RexShuttle shuttle = new RegisterOutputShuttle(exprList); // For each project, lookup the expr and expand it so it is in terms of // bottomCalc's input fields for (RexLocalRef topProject : program.getProjectList()) { final RexNode topExpr = exprList.get(topProject.getIndex()); final RexLocalRef expanded = (RexLocalRef) topExpr.accept(shuttle); // Remember the expr, but don't add to the project list yet. projectRefList.add(expanded); } // Similarly for the condition. final RexLocalRef topCondition = program.getCondition(); if (topCondition != null) { final RexNode topExpr = exprList.get(topCondition.getIndex()); final RexLocalRef expanded = (RexLocalRef) topExpr.accept(shuttle); addCondition(registerInput(expanded)); } return projectRefList; }
private List<RexLocalRef> registerProjectsAndCondition(RexProgram program) { final List<RexNode> exprList = program.getExprList(); final List<RexLocalRef> projectRefList = new ArrayList<>(); final RexShuttle shuttle = new RegisterOutputShuttle(exprList); // For each project, lookup the expr and expand it so it is in terms of // bottomCalc's input fields for (RexLocalRef topProject : program.getProjectList()) { final RexNode topExpr = exprList.get(topProject.getIndex()); final RexLocalRef expanded = (RexLocalRef) topExpr.accept(shuttle); // Remember the expr, but don't add to the project list yet. projectRefList.add(expanded); } // Similarly for the condition. final RexLocalRef topCondition = program.getCondition(); if (topCondition != null) { final RexNode topExpr = exprList.get(topCondition.getIndex()); final RexLocalRef expanded = (RexLocalRef) topExpr.accept(shuttle); addCondition(registerInput(expanded)); } return projectRefList; }
final List<RexLocalRef> list = new ArrayList<>(); for (RexNode expr : expandedExprList) { list.add(builder.registerInput(expr));
final List<RexLocalRef> list = new ArrayList<>(); for (RexNode expr : expandedExprList) { list.add(builder.registerInput(expr));
final RewriteRexShuttle shuttle = new RewriteRexShuttle(); for (RexNode expr : program.getExprList()) { programBuilder.registerInput(expr.accept(shuttle));
final RewriteRexShuttle shuttle = new RewriteRexShuttle(); for (RexNode expr : program.getExprList()) { programBuilder.registerInput(expr.accept(shuttle));