/** * Creates a program. * * <p>The expressions must be valid: they must not contain common expressions, * forward references, or non-trivial aggregates.</p> * * @param inputRowType Input row type * @param exprs Common expressions * @param projects Projection expressions * @param condition Condition expression. If null, calculator does not * filter rows * @param outputRowType Description of the row produced by the program */ public RexProgram( RelDataType inputRowType, List<? extends RexNode> exprs, List<RexLocalRef> projects, RexLocalRef condition, RelDataType outputRowType) { this.inputRowType = inputRowType; this.exprs = ImmutableList.copyOf(exprs); this.projects = ImmutableList.copyOf(projects); this.condition = condition; this.outputRowType = outputRowType; assert isValid(Litmus.THROW, null); }
/** * Creates a program. * * <p>The expressions must be valid: they must not contain common expressions, * forward references, or non-trivial aggregates.</p> * * @param inputRowType Input row type * @param exprs Common expressions * @param projects Projection expressions * @param condition Condition expression. If null, calculator does not * filter rows * @param outputRowType Description of the row produced by the program */ public RexProgram( RelDataType inputRowType, List<? extends RexNode> exprs, List<RexLocalRef> projects, RexLocalRef condition, RelDataType outputRowType) { this.inputRowType = inputRowType; this.exprs = ImmutableList.copyOf(exprs); this.projects = ImmutableList.copyOf(projects); this.condition = condition; this.outputRowType = outputRowType; assert isValid(Litmus.THROW, null); }
/** * Creates a simplified/normalized copy of this program. * * @param rexBuilder Rex builder * @param simplify Simplifier to simplify (in addition to normalizing), * or null to not simplify * @return Normalized program */ public RexProgram normalize(RexBuilder rexBuilder, RexSimplify simplify) { // Normalize program by creating program builder from the program, then // converting to a program. getProgram does not need to normalize // because the builder was normalized on creation. assert isValid(Litmus.THROW, null); final RexProgramBuilder builder = RexProgramBuilder.create(rexBuilder, inputRowType, exprs, projects, condition, outputRowType, true, simplify); return builder.getProgram(false); }
/** * Creates a simplified/normalized copy of this program. * * @param rexBuilder Rex builder * @param simplify Simplifier to simplify (in addition to normalizing), * or null to not simplify * @return Normalized program */ public RexProgram normalize(RexBuilder rexBuilder, RexSimplify simplify) { // Normalize program by creating program builder from the program, then // converting to a program. getProgram does not need to normalize // because the builder was normalized on creation. assert isValid(Litmus.THROW, null); final RexProgramBuilder builder = RexProgramBuilder.create(rexBuilder, inputRowType, exprs, projects, condition, outputRowType, true, simplify); return builder.getProgram(false); }
assert bottomProgram.isValid(Litmus.THROW, null); assert topProgram.isValid(Litmus.THROW, null); final RexProgramBuilder progBuilder = RexProgramBuilder.forProgram(bottomProgram, rexBuilder, false); assert mergedProg.isValid(Litmus.THROW, null); assert mergedProg.getOutputRowType() == topProgram.getOutputRowType(); return mergedProg;
assert bottomProgram.isValid(Litmus.THROW, null); assert topProgram.isValid(Litmus.THROW, null); final RexProgramBuilder progBuilder = RexProgramBuilder.forProgram(bottomProgram, rexBuilder, false); assert mergedProg.isValid(Litmus.THROW, null); assert mergedProg.getOutputRowType() == topProgram.getOutputRowType(); return mergedProg;
RexBuilder rexBuilder, boolean normalize) { assert program.isValid(Litmus.THROW, null); final RelDataType inputRowType = program.getInputRowType(); final List<RexLocalRef> projectRefs = program.getProjectList();
RexBuilder rexBuilder, boolean normalize) { assert program.isValid(Litmus.THROW, null); final RelDataType inputRowType = program.getInputRowType(); final List<RexLocalRef> projectRefs = program.getProjectList();
public boolean isValid(Litmus litmus, Context context) { if (!RelOptUtil.equal( "program's input type", program.getInputRowType(), "child's output type", getInput().getRowType(), litmus)) { return litmus.fail(null); } if (!program.isValid(litmus, context)) { return litmus.fail(null); } if (!program.isNormalized(litmus, getCluster().getRexBuilder())) { return litmus.fail(null); } return litmus.succeed(); }
public boolean isValid(Litmus litmus, Context context) { if (!RelOptUtil.equal( "program's input type", program.getInputRowType(), "child's output type", getInput().getRowType(), litmus)) { return litmus.fail(null); } if (!program.isValid(litmus, context)) { return litmus.fail(null); } if (!program.isNormalized(litmus, getCluster().getRexBuilder())) { return litmus.fail(null); } return litmus.succeed(); }
assert program.isValid(Litmus.THROW, null); final List<RexNode> exprList = program.getExprList(); final RexNode[] exprs = exprList.toArray(new RexNode[0]);
assert program.isValid(Litmus.THROW, null); final List<RexNode> exprList = program.getExprList(); final RexNode[] exprs = exprList.toArray(new RexNode[0]);