/** * Creates a program that projects its input fields but with possibly * different names for the output fields. */ public static RexProgram createIdentity( RelDataType rowType, RelDataType outputRowType) { if (rowType != outputRowType && !Pair.right(rowType.getFieldList()).equals( Pair.right(outputRowType.getFieldList()))) { throw new IllegalArgumentException( "field type mismatch: " + rowType + " vs. " + outputRowType); } final List<RelDataTypeField> fields = rowType.getFieldList(); final List<RexLocalRef> projectRefs = new ArrayList<>(); final List<RexInputRef> refs = new ArrayList<>(); for (int i = 0; i < fields.size(); i++) { final RexInputRef ref = RexInputRef.of(i, fields); refs.add(ref); projectRefs.add(new RexLocalRef(i, ref.getType())); } return new RexProgram(rowType, refs, projectRefs, null, outputRowType); }
/** * Creates a program that projects its input fields but with possibly * different names for the output fields. */ public static RexProgram createIdentity( RelDataType rowType, RelDataType outputRowType) { if (rowType != outputRowType && !Pair.right(rowType.getFieldList()).equals( Pair.right(outputRowType.getFieldList()))) { throw new IllegalArgumentException( "field type mismatch: " + rowType + " vs. " + outputRowType); } final List<RelDataTypeField> fields = rowType.getFieldList(); final List<RexLocalRef> projectRefs = new ArrayList<>(); final List<RexInputRef> refs = new ArrayList<>(); for (int i = 0; i < fields.size(); i++) { final RexInputRef ref = RexInputRef.of(i, fields); refs.add(ref); projectRefs.add(new RexLocalRef(i, ref.getType())); } return new RexProgram(rowType, refs, projectRefs, null, outputRowType); }
return new RexProgram( inputRowType, exprList,
return new RexProgram( inputRowType, exprList,
public RexProgram copyOf(RexProgram program) { return new RexProgram( copyOf(program.getInputRowType()), copyRexNodes(program.getExprList()), Lists.transform(program.getProjectList(), COPY_REX_LOCAL_REF), (RexLocalRef) copyOf(program.getCondition()), copyOf(program.getOutputRowType()) ); }
new RexProgram( inputRowType, exprs, projectRefs, conditionRef, outputRowType);
new RexProgram( inputRowType, exprs, projectRefs, conditionRef, outputRowType);
new RexProgram( rel.getRowType(), exprList,
new RexProgram( rel.getRowType(), exprList,
public RelNode accept(RexShuttle shuttle) { List<RexNode> oldExprs = program.getExprList(); List<RexNode> exprs = shuttle.apply(oldExprs); List<RexLocalRef> oldProjects = program.getProjectList(); List<RexLocalRef> projects = shuttle.apply(oldProjects); RexLocalRef oldCondition = program.getCondition(); RexNode condition; if (oldCondition != null) { condition = shuttle.apply(oldCondition); assert condition instanceof RexLocalRef : "Invalid condition after rewrite. Expected RexLocalRef, got " + condition; } else { condition = null; } if (exprs == oldExprs && projects == oldProjects && condition == oldCondition) { return this; } return copy(traitSet, getInput(), new RexProgram(program.getInputRowType(), exprs, projects, (RexLocalRef) condition, program.getOutputRowType())); } }
public RelNode accept(RexShuttle shuttle) { List<RexNode> oldExprs = program.getExprList(); List<RexNode> exprs = shuttle.apply(oldExprs); List<RexLocalRef> oldProjects = program.getProjectList(); List<RexLocalRef> projects = shuttle.apply(oldProjects); RexLocalRef oldCondition = program.getCondition(); RexNode condition; if (oldCondition != null) { condition = shuttle.apply(oldCondition); assert condition instanceof RexLocalRef : "Invalid condition after rewrite. Expected RexLocalRef, got " + condition; } else { condition = null; } if (exprs == oldExprs && projects == oldProjects && condition == oldCondition) { return this; } return copy(traitSet, getInput(), new RexProgram(program.getInputRowType(), exprs, projects, (RexLocalRef) condition, program.getOutputRowType())); } }