public void onMatch(RelOptRuleCall call) { final LogicalCorrelate correlate = call.rel(0); final RelNode left = call.rel(1); final LogicalProject aggOutputProject; final LogicalAggregate aggregate; if (flavor) { aggOutputProject = call.rel(2); aggregate = call.rel(3); } else { aggregate = call.rel(2); // Create identity projection final List<Pair<RexNode, String>> projects = new ArrayList<>(); final List<RelDataTypeField> fields = aggregate.getRowType().getFieldList(); for (int i = 0; i < fields.size(); i++) { projects.add(RexInputRef.of2(projects.size(), fields)); } final RelBuilder relBuilder = call.builder(); relBuilder.push(aggregate) .projectNamed(Pair.left(projects), Pair.right(projects), true); aggOutputProject = (LogicalProject) relBuilder.build(); } onMatch2(call, correlate, left, aggOutputProject, aggregate); }
.addRuleInstance(new AdjustProjectForCountAggregateRule(false, f)) .addRuleInstance(new AdjustProjectForCountAggregateRule(true, f)) .addRuleInstance( new FilterJoinRule.FilterIntoJoinRule(true, f,
.addRuleInstance(new AdjustProjectForCountAggregateRule(false, f)) .addRuleInstance(new AdjustProjectForCountAggregateRule(true, f)) .addRuleInstance( new FilterJoinRule.FilterIntoJoinRule(true, f,
private RelNode decorrelate(RelNode root) { // first adjust count() expression if any HepProgram program = HepProgram.builder() .addRuleInstance(new AdjustProjectForCountAggregateRule(false)) .addRuleInstance(new AdjustProjectForCountAggregateRule(true)) .addRuleInstance(FilterJoinRule.FILTER_ON_JOIN) .addRuleInstance(FilterProjectTransposeRule.INSTANCE) .addRuleInstance(FilterCorrelateRule.INSTANCE) .build(); HepPlanner planner = createPlanner(program); planner.setRoot(root); root = planner.findBestExp(); // Perform decorrelation. map.clear(); final Frame frame = getInvoke(root, null); if (frame != null) { // has been rewritten; apply rules post-decorrelation final HepProgram program2 = HepProgram.builder() .addRuleInstance(FilterJoinRule.FILTER_ON_JOIN) .addRuleInstance(FilterJoinRule.JOIN) .build(); final HepPlanner planner2 = createPlanner(program2); final RelNode newRoot = frame.r; planner2.setRoot(newRoot); return planner2.findBestExp(); } return root; }
public void onMatch(RelOptRuleCall call) { final LogicalCorrelate correlate = call.rel(0); final RelNode left = call.rel(1); final LogicalProject aggOutputProject; final LogicalAggregate aggregate; if (flavor) { aggOutputProject = call.rel(2); aggregate = call.rel(3); } else { aggregate = call.rel(2); // Create identity projection final List<Pair<RexNode, String>> projects = new ArrayList<>(); final List<RelDataTypeField> fields = aggregate.getRowType().getFieldList(); for (int i = 0; i < fields.size(); i++) { projects.add(RexInputRef.of2(projects.size(), fields)); } final RelBuilder relBuilder = call.builder(); relBuilder.push(aggregate) .projectNamed(Pair.left(projects), Pair.right(projects), true); aggOutputProject = (LogicalProject) relBuilder.build(); } onMatch2(call, correlate, left, aggOutputProject, aggregate); }
public void onMatch(RelOptRuleCall call) { final LogicalCorrelate correlate = call.rel(0); final RelNode left = call.rel(1); final LogicalProject aggOutputProject; final LogicalAggregate aggregate; if (flavor) { aggOutputProject = call.rel(2); aggregate = call.rel(3); } else { aggregate = call.rel(2); // Create identity projection final List<Pair<RexNode, String>> projects = Lists.newArrayList(); final List<RelDataTypeField> fields = aggregate.getRowType().getFieldList(); for (int i = 0; i < fields.size(); i++) { projects.add(RexInputRef.of2(projects.size(), fields)); } final RelBuilder relBuilder = call.builder(); relBuilder.push(aggregate) .projectNamed(Pair.left(projects), Pair.right(projects), true); aggOutputProject = (LogicalProject) relBuilder.build(); } onMatch2(call, correlate, left, aggOutputProject, aggregate); }
AdjustProjectForCountAggregateRule(boolean flavor, RelBuilderFactory relBuilderFactory) { super( flavor ? operand(LogicalCorrelate.class, operand(RelNode.class, any()), operand(LogicalProject.class, operand(LogicalAggregate.class, any()))) : operand(LogicalCorrelate.class, operand(RelNode.class, any()), operand(LogicalAggregate.class, any())), relBuilderFactory, null); this.flavor = flavor; }
AdjustProjectForCountAggregateRule(boolean flavor, RelBuilderFactory relBuilderFactory) { super( flavor ? operand(LogicalCorrelate.class, operand(RelNode.class, any()), operand(LogicalProject.class, operand(LogicalAggregate.class, any()))) : operand(LogicalCorrelate.class, operand(RelNode.class, any()), operand(LogicalAggregate.class, any())), relBuilderFactory, null); this.flavor = flavor; }
AdjustProjectForCountAggregateRule(boolean flavor) { super( flavor ? operand(LogicalCorrelate.class, operand(RelNode.class, any()), operand(LogicalProject.class, operand(LogicalAggregate.class, any()))) : operand(LogicalCorrelate.class, operand(RelNode.class, any()), operand(LogicalAggregate.class, any()))); this.flavor = flavor; }