@Override public boolean matches(RelOptRuleCall call) { final Aggregate aggregate = call.rel(0); // Rule cannot be applied if there are GroupingId because it will change the // value as the position will be changed. for (AggregateCall aggCall : aggregate.getAggCallList()) { if (aggCall.getAggregation().equals(HiveGroupingID.INSTANCE)) { return false; } } return super.matches(call); }
public void onMatch(RelOptRuleCall call) { final Aggregate aggregate = call.rel(0); final Project project = call.rel(1); RelNode x = apply(call, aggregate, project); if (x != null) { call.transformTo(x); } }
public void onMatch(RelOptRuleCall call) { final Aggregate aggregate = call.rel(0); final Project project = call.rel(1); RelNode x = apply(call, aggregate, project); if (x != null) { call.transformTo(x); } }
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); } } }
@Override public void onMatch(RelOptRuleCall call) { final Aggregate aggregate = call.rel(0); final Project project = call.rel(1); final StarTable.StarTableScan scan = call.rel(2); final RelNode rel = AggregateProjectMergeRule.apply(call, aggregate, project); final Aggregate aggregate2; final Project project2; if (rel instanceof Aggregate) { project2 = null; aggregate2 = (Aggregate) rel; } else if (rel instanceof Project) { project2 = (Project) rel; aggregate2 = (Aggregate) project2.getInput(); } else { return; } apply(call, project2, aggregate2, scan); } };
@Override public void onMatch(RelOptRuleCall call) { final Aggregate aggregate = call.rel(0); final Project project = call.rel(1); final StarTable.StarTableScan scan = call.rel(2); final RelNode rel = AggregateProjectMergeRule.apply(call, aggregate, project); final Aggregate aggregate2; final Project project2; if (rel instanceof Aggregate) { project2 = null; aggregate2 = (Aggregate) rel; } else if (rel instanceof Project) { project2 = (Project) rel; aggregate2 = (Aggregate) project2.getInput(); } else { return; } apply(call, project2, aggregate2, scan); } };
@Override public void onMatch(RelOptRuleCall call) { final Aggregate aggregate = call.rel(0); final Project project = call.rel(1); final StarTable.StarTableScan scan = call.rel(2); final RelNode rel = AggregateProjectMergeRule.apply(call, aggregate, project); final Aggregate aggregate2; final Project project2; if (rel instanceof Aggregate) { project2 = null; aggregate2 = (Aggregate) rel; } else if (rel instanceof Project) { project2 = (Project) rel; aggregate2 = (Aggregate) project2.getInput(); } else { return; } apply(call, project2, aggregate2, scan); } };
AggregateProjectMergeRule.apply(call, aggregate2, project);