@Override public RelNode convert(RelNode rel) { final Calc calc = (Calc) rel; final RelNode input = calc.getInput(); return new StreamsCalcRel(calc.getCluster(), calc.getTraitSet().replace(StreamsLogicalConvention.INSTANCE), convert(input, input.getTraitSet().replace(StreamsLogicalConvention.INSTANCE)), calc.getProgram()); } }
public void onMatch(RelOptRuleCall call) { final Aggregate aggregate = call.rel(0); final Calc calc = call.rel(1); final RexProgram program = calc.getProgram(); final List<RexNode> projects = new ArrayList<>(); for (RexLocalRef localRef : program.getProjectList()) { projects.add(program.expandLocalRef(localRef)); } final Project project = LogicalProject.create(calc.getInput(), projects, calc.getRowType()); RelNode x = AggregateProjectMergeRule.apply(call, aggregate, project); if (x != null) { call.transformTo(x); } } }
public Double getRowCount(Calc rel, RelMetadataQuery mq) { return RelMdUtil.estimateFilteredRows(rel.getInput(), rel.getProgram(), mq); }
public RelNode convert(RelNode rel) { final Calc calc = (Calc) rel; // If there's a multiset, let FarragoMultisetSplitter work on it // first. if (RexMultisetUtil.containsMultiset(calc.getProgram())) { return null; } return new JdbcCalc(rel.getCluster(), rel.getTraitSet().replace(out), convert(calc.getInput(), calc.getTraitSet().replace(out)), calc.getProgram()); } }
/** Predicate for whether a {@link Calc} contains multisets or windowed * aggregates. */ public static boolean containsMultisetOrWindowedAgg(Calc calc) { return !(B && RexMultisetUtil.containsMultiset(calc.getProgram()) || calc.getProgram().containsAggs()); }
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 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())); } }
@Override public double estimateRowCount(RelMetadataQuery mq) { return RelMdUtil.estimateFilteredRows(getInput(), program, mq); }
@Deprecated // to be removed before 2.0 public Calc copy( RelTraitSet traitSet, RelNode child, RexProgram program, List<RelCollation> collationList) { Util.discard(collationList); return copy(traitSet, child, program); }
/** * Creates a Calc. * * @param cluster Cluster * @param traits Traits * @param child Input relation * @param program Calc program */ protected Calc( RelOptCluster cluster, RelTraitSet traits, RelNode child, RexProgram program) { super(cluster, traits, child); this.rowType = program.getOutputRowType(); this.program = program; assert isValid(Litmus.THROW, null); }
@Override public void onMatch(RelOptRuleCall call) { final Calc calc = call.rel(0); final Pair<ImmutableList<RexNode>, ImmutableList<RexNode>> projectFilter = calc.getProgram().split(); final RelBuilder relBuilder = call.builder(); relBuilder.push(calc.getInput()); relBuilder.filter(projectFilter.right); relBuilder.project(projectFilter.left, calc.getRowType().getFieldNames()); call.transformTo(relBuilder.build()); } }
public ImmutableList<RelCollation> collations(Calc calc, RelMetadataQuery mq) { return ImmutableList.copyOf(calc(mq, calc.getInput(), calc.getProgram())); }
public RelNode convert(RelNode rel) { final Calc calc = (Calc) rel; // If there's a multiset, let FarragoMultisetSplitter work on it // first. if (RexMultisetUtil.containsMultiset(calc.getProgram())) { return null; } return new JdbcCalc(rel.getCluster(), rel.getTraitSet().replace(out), convert(calc.getInput(), calc.getTraitSet().replace(out)), calc.getProgram()); } }
/** Predicate for whether a {@link Calc} contains multisets or windowed * aggregates. */ public static boolean containsMultisetOrWindowedAgg(Calc calc) { return !(B && RexMultisetUtil.containsMultiset(calc.getProgram()) || calc.getProgram().containsAggs()); }
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 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())); } }
@Override public double estimateRowCount(RelMetadataQuery mq) { return RelMdUtil.estimateFilteredRows(getInput(), program, mq); }
@Deprecated // to be removed before 2.0 public Calc copy( RelTraitSet traitSet, RelNode child, RexProgram program, List<RelCollation> collationList) { Util.discard(collationList); return copy(traitSet, child, program); }