org.apache.calcite.rel.rules.FilterAggregateTransposeRule Java Examples
The following examples show how to use
org.apache.calcite.rel.rules.FilterAggregateTransposeRule.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PigRelBuilderStyleTest.java From calcite with Apache License 2.0 | 6 votes |
private RelOptPlanner getVolcanoPlanner(RelNode root) { final RelBuilderFactory builderFactory = RelBuilder.proto(PigRelFactories.ALL_PIG_REL_FACTORIES); final RelOptPlanner planner = root.getCluster().getPlanner(); // VolcanoPlanner for (RelOptRule r : PigRules.ALL_PIG_OPT_RULES) { planner.addRule(r); } planner.removeRule(FilterAggregateTransposeRule.INSTANCE); planner.removeRule(FilterJoinRule.FILTER_ON_JOIN); planner.addRule( new FilterAggregateTransposeRule(PigFilter.class, builderFactory, PigAggregate.class)); planner.addRule( new FilterIntoJoinRule(true, builderFactory, TRUE_PREDICATE)); planner.setRoot(root); return planner; }
Example #2
Source File: MaterializedViewSubstitutionVisitorTest.java From calcite with Apache License 2.0 | 6 votes |
private RelNode canonicalize(RelNode rel) { HepProgram program = new HepProgramBuilder() .addRuleInstance(FilterProjectTransposeRule.INSTANCE) .addRuleInstance(FilterMergeRule.INSTANCE) .addRuleInstance(FilterJoinRule.FILTER_ON_JOIN) .addRuleInstance(FilterJoinRule.JOIN) .addRuleInstance(FilterAggregateTransposeRule.INSTANCE) .addRuleInstance(ProjectMergeRule.INSTANCE) .addRuleInstance(ProjectRemoveRule.INSTANCE) .addRuleInstance(ProjectJoinTransposeRule.INSTANCE) .addRuleInstance(ProjectSetOpTransposeRule.INSTANCE) .addRuleInstance(FilterToCalcRule.INSTANCE) .addRuleInstance(ProjectToCalcRule.INSTANCE) .addRuleInstance(FilterCalcMergeRule.INSTANCE) .addRuleInstance(ProjectCalcMergeRule.INSTANCE) .addRuleInstance(CalcMergeRule.INSTANCE) .build(); final HepPlanner hepPlanner = new HepPlanner(program); hepPlanner.setRoot(rel); return hepPlanner.findBestExp(); }
Example #3
Source File: MaterializedViewAggregateRule.java From calcite with Apache License 2.0 | 5 votes |
/** Creates a MaterializedViewAggregateRule. */ protected MaterializedViewAggregateRule(RelOptRuleOperand operand, RelBuilderFactory relBuilderFactory, String description, boolean generateUnionRewriting, HepProgram unionRewritingPullProgram) { this(operand, relBuilderFactory, description, generateUnionRewriting, unionRewritingPullProgram, new FilterProjectTransposeRule( Filter.class, Project.class, true, true, relBuilderFactory), new FilterAggregateTransposeRule( Filter.class, relBuilderFactory, Aggregate.class), new AggregateProjectPullUpConstantsRule( Aggregate.class, Filter.class, relBuilderFactory, "AggFilterPullUpConstants"), new ProjectMergeRule(true, ProjectMergeRule.DEFAULT_BLOAT, relBuilderFactory)); }
Example #4
Source File: RelOptMaterializations.java From calcite with Apache License 2.0 | 4 votes |
private static List<RelNode> substitute( RelNode root, RelOptMaterialization materialization) { // First, if the materialization is in terms of a star table, rewrite // the query in terms of the star table. if (materialization.starTable != null) { RelNode newRoot = RelOptMaterialization.tryUseStar(root, materialization.starRelOptTable); if (newRoot != null) { root = newRoot; } } // Push filters to the bottom, and combine projects on top. RelNode target = materialization.queryRel; // try to trim unused field in relational expressions. root = trimUnusedfields(root); target = trimUnusedfields(target); HepProgram program = new HepProgramBuilder() .addRuleInstance(FilterProjectTransposeRule.INSTANCE) .addRuleInstance(FilterMergeRule.INSTANCE) .addRuleInstance(FilterJoinRule.FILTER_ON_JOIN) .addRuleInstance(FilterJoinRule.JOIN) .addRuleInstance(FilterAggregateTransposeRule.INSTANCE) .addRuleInstance(ProjectMergeRule.INSTANCE) .addRuleInstance(ProjectRemoveRule.INSTANCE) .addRuleInstance(ProjectJoinTransposeRule.INSTANCE) .addRuleInstance(ProjectSetOpTransposeRule.INSTANCE) .addRuleInstance(FilterToCalcRule.INSTANCE) .addRuleInstance(ProjectToCalcRule.INSTANCE) .addRuleInstance(FilterCalcMergeRule.INSTANCE) .addRuleInstance(ProjectCalcMergeRule.INSTANCE) .addRuleInstance(CalcMergeRule.INSTANCE) .build(); // We must use the same HEP planner for the two optimizations below. // Thus different nodes with the same digest will share the same vertex in // the plan graph. This is important for the matching process. final HepPlanner hepPlanner = new HepPlanner(program); hepPlanner.setRoot(target); target = hepPlanner.findBestExp(); hepPlanner.setRoot(root); root = hepPlanner.findBestExp(); return new SubstitutionVisitor(target, root).go(materialization.tableRel); }