org.apache.calcite.plan.volcano.AbstractConverter.ExpandConversionRule Java Examples
The following examples show how to use
org.apache.calcite.plan.volcano.AbstractConverter.ExpandConversionRule.
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: CollationConversionTest.java From calcite with Apache License 2.0 | 5 votes |
@Test void testCollationConversion() { final VolcanoPlanner planner = new VolcanoPlanner(); planner.addRelTraitDef(ConventionTraitDef.INSTANCE); planner.addRelTraitDef(COLLATION_TRAIT_DEF); planner.addRule(new SingleNodeRule()); planner.addRule(new LeafTraitRule()); planner.addRule(ExpandConversionRule.INSTANCE); planner.setTopDownOpt(false); final RelOptCluster cluster = newCluster(planner); final NoneLeafRel leafRel = new NoneLeafRel(cluster, "a"); final NoneSingleRel singleRel = new NoneSingleRel(cluster, leafRel); final RelNode convertedRel = planner.changeTraits(singleRel, cluster.traitSetOf(PHYS_CALLING_CONVENTION).plus(ROOT_COLLATION)); planner.setRoot(convertedRel); RelNode result = planner.chooseDelegate().findBestExp(); assertTrue(result instanceof RootSingleRel); assertTrue(result.getTraitSet().contains(ROOT_COLLATION)); assertTrue(result.getTraitSet().contains(PHYS_CALLING_CONVENTION)); final RelNode input = result.getInput(0); assertTrue(input instanceof PhysicalSort); assertTrue(result.getTraitSet().contains(ROOT_COLLATION)); assertTrue(input.getTraitSet().contains(PHYS_CALLING_CONVENTION)); final RelNode input2 = input.getInput(0); assertTrue(input2 instanceof LeafRel); assertTrue(input2.getTraitSet().contains(LEAF_COLLATION)); assertTrue(input.getTraitSet().contains(PHYS_CALLING_CONVENTION)); }
Example #2
Source File: TraitConversionTest.java From calcite with Apache License 2.0 | 5 votes |
@Test void testTraitConversion() { final VolcanoPlanner planner = new VolcanoPlanner(); planner.addRelTraitDef(ConventionTraitDef.INSTANCE); planner.addRelTraitDef(NEW_TRAIT_DEF_INSTANCE); planner.addRule(new RandomSingleTraitRule()); planner.addRule(new SingleLeafTraitRule()); planner.addRule(ExpandConversionRule.INSTANCE); planner.setTopDownOpt(false); final RelOptCluster cluster = newCluster(planner); final NoneLeafRel leafRel = new NoneLeafRel(cluster, "a"); final NoneSingleRel singleRel = new NoneSingleRel(cluster, leafRel); final RelNode convertedRel = planner.changeTraits(singleRel, cluster.traitSetOf(PHYS_CALLING_CONVENTION)); planner.setRoot(convertedRel); final RelNode result = planner.chooseDelegate().findBestExp(); assertTrue(result instanceof RandomSingleRel); assertTrue(result.getTraitSet().contains(PHYS_CALLING_CONVENTION)); assertTrue(result.getTraitSet().contains(SIMPLE_DISTRIBUTION_RANDOM)); final RelNode input = result.getInput(0); assertTrue(input instanceof BridgeRel); assertTrue(input.getTraitSet().contains(PHYS_CALLING_CONVENTION)); assertTrue(input.getTraitSet().contains(SIMPLE_DISTRIBUTION_RANDOM)); final RelNode input2 = input.getInput(0); assertTrue(input2 instanceof SingletonLeafRel); assertTrue(input2.getTraitSet().contains(PHYS_CALLING_CONVENTION)); assertTrue(input2.getTraitSet().contains(SIMPLE_DISTRIBUTION_SINGLETON)); }
Example #3
Source File: OLAPTableScan.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
@Override public void register(RelOptPlanner planner) { // force clear the query context before traversal relational operators OLAPContext.clearThreadLocalContexts(); // register OLAP rules addRules(planner, kylinConfig.getCalciteAddRule()); planner.addRule(OLAPToEnumerableConverterRule.INSTANCE); planner.addRule(OLAPFilterRule.INSTANCE); planner.addRule(OLAPProjectRule.INSTANCE); planner.addRule(OLAPAggregateRule.INSTANCE); planner.addRule(OLAPJoinRule.INSTANCE); planner.addRule(OLAPLimitRule.INSTANCE); planner.addRule(OLAPSortRule.INSTANCE); planner.addRule(OLAPUnionRule.INSTANCE); planner.addRule(OLAPWindowRule.INSTANCE); planner.addRule(OLAPValuesRule.INSTANCE); planner.addRule(AggregateProjectReduceRule.INSTANCE); // CalcitePrepareImpl.CONSTANT_REDUCTION_RULES if (kylinConfig.isReduceExpressionsRulesEnabled()) { planner.addRule(ReduceExpressionsRule.PROJECT_INSTANCE); planner.addRule(ReduceExpressionsRule.FILTER_INSTANCE); planner.addRule(ReduceExpressionsRule.CALC_INSTANCE); planner.addRule(ReduceExpressionsRule.JOIN_INSTANCE); } // the ValuesReduceRule breaks query test somehow... // planner.addRule(ValuesReduceRule.FILTER_INSTANCE); // planner.addRule(ValuesReduceRule.PROJECT_FILTER_INSTANCE); // planner.addRule(ValuesReduceRule.PROJECT_INSTANCE); removeRules(planner, kylinConfig.getCalciteRemoveRule()); if (!kylinConfig.isEnumerableRulesEnabled()) { for (RelOptRule rule : CalcitePrepareImpl.ENUMERABLE_RULES) { planner.removeRule(rule); } } // since join is the entry point, we can't push filter past join planner.removeRule(FilterJoinRule.FILTER_ON_JOIN); planner.removeRule(FilterJoinRule.JOIN); // since we don't have statistic of table, the optimization of join is too cost planner.removeRule(JoinCommuteRule.INSTANCE); planner.removeRule(JoinPushThroughJoinRule.LEFT); planner.removeRule(JoinPushThroughJoinRule.RIGHT); // keep tree structure like filter -> aggregation -> project -> join/table scan, implementOLAP() rely on this tree pattern planner.removeRule(AggregateJoinTransposeRule.INSTANCE); planner.removeRule(AggregateProjectMergeRule.INSTANCE); planner.removeRule(FilterProjectTransposeRule.INSTANCE); planner.removeRule(SortJoinTransposeRule.INSTANCE); planner.removeRule(JoinPushExpressionsRule.INSTANCE); planner.removeRule(SortUnionTransposeRule.INSTANCE); planner.removeRule(JoinUnionTransposeRule.LEFT_UNION); planner.removeRule(JoinUnionTransposeRule.RIGHT_UNION); planner.removeRule(AggregateUnionTransposeRule.INSTANCE); planner.removeRule(DateRangeRules.FILTER_INSTANCE); planner.removeRule(SemiJoinRule.JOIN); planner.removeRule(SemiJoinRule.PROJECT); // distinct count will be split into a separated query that is joined with the left query planner.removeRule(AggregateExpandDistinctAggregatesRule.INSTANCE); // see Dec 26th email @ http://mail-archives.apache.org/mod_mbox/calcite-dev/201412.mbox/browser planner.removeRule(ExpandConversionRule.INSTANCE); }
Example #4
Source File: PlannerPhase.java From dremio-oss with Apache License 2.0 | 4 votes |
static final RuleSet getPhysicalRules(OptimizerRulesContext optimizerRulesContext) { final List<RelOptRule> ruleList = new ArrayList<>(); final PlannerSettings ps = optimizerRulesContext.getPlannerSettings(); ruleList.add(SortConvertPrule.INSTANCE); ruleList.add(SortPrule.INSTANCE); ruleList.add(ProjectPrule.INSTANCE); ruleList.add(FlattenPrule.INSTANCE); ruleList.add(ScreenPrule.INSTANCE); ruleList.add(ExpandConversionRule.INSTANCE); ruleList.add(FilterPrule.INSTANCE); ruleList.add(LimitPrule.INSTANCE); ruleList.add(SamplePrule.INSTANCE); ruleList.add(SampleToLimitPrule.INSTANCE); ruleList.add(WriterPrule.INSTANCE); ruleList.add(WindowPrule.INSTANCE); ruleList.add(PushLimitToTopN.INSTANCE); ruleList.add(LimitUnionExchangeTransposeRule.INSTANCE); ruleList.add(UnionAllPrule.INSTANCE); ruleList.add(ValuesPrule.INSTANCE); ruleList.add(EmptyPrule.INSTANCE); ruleList.add(PushLimitToPruneableScan.INSTANCE); if (ps.isHashAggEnabled()) { ruleList.add(HashAggPrule.INSTANCE); } if (ps.isStreamAggEnabled()) { ruleList.add(StreamAggPrule.INSTANCE); } if (ps.isHashJoinEnabled()) { ruleList.add(HashJoinPrule.DIST_INSTANCE); if(ps.isBroadcastJoinEnabled()){ ruleList.add(HashJoinPrule.BROADCAST_INSTANCE); } } if (ps.isMergeJoinEnabled()) { ruleList.add(MergeJoinPrule.DIST_INSTANCE); if(ps.isBroadcastJoinEnabled()){ ruleList.add(MergeJoinPrule.BROADCAST_INSTANCE); } } // NLJ plans consist of broadcasting the right child, hence we need // broadcast join enabled. if (ps.isNestedLoopJoinEnabled() && ps.isBroadcastJoinEnabled()) { ruleList.add(NestedLoopJoinPrule.INSTANCE); } return RuleSets.ofList(ImmutableSet.copyOf(ruleList)); }
Example #5
Source File: OLAPTableScan.java From kylin with Apache License 2.0 | 4 votes |
@Override public void register(RelOptPlanner planner) { // force clear the query context before traversal relational operators OLAPContext.clearThreadLocalContexts(); // register OLAP rules addRules(planner, kylinConfig.getCalciteAddRule()); planner.addRule(OLAPToEnumerableConverterRule.INSTANCE); planner.addRule(OLAPFilterRule.INSTANCE); planner.addRule(OLAPProjectRule.INSTANCE); planner.addRule(OLAPAggregateRule.INSTANCE); planner.addRule(OLAPJoinRule.INSTANCE); planner.addRule(OLAPLimitRule.INSTANCE); planner.addRule(OLAPSortRule.INSTANCE); planner.addRule(OLAPUnionRule.INSTANCE); planner.addRule(OLAPWindowRule.INSTANCE); planner.addRule(OLAPValuesRule.INSTANCE); planner.addRule(AggregateProjectReduceRule.INSTANCE); // CalcitePrepareImpl.CONSTANT_REDUCTION_RULES if (kylinConfig.isReduceExpressionsRulesEnabled()) { planner.addRule(ReduceExpressionsRule.PROJECT_INSTANCE); planner.addRule(ReduceExpressionsRule.FILTER_INSTANCE); planner.addRule(ReduceExpressionsRule.CALC_INSTANCE); planner.addRule(ReduceExpressionsRule.JOIN_INSTANCE); } // the ValuesReduceRule breaks query test somehow... // planner.addRule(ValuesReduceRule.FILTER_INSTANCE); // planner.addRule(ValuesReduceRule.PROJECT_FILTER_INSTANCE); // planner.addRule(ValuesReduceRule.PROJECT_INSTANCE); removeRules(planner, kylinConfig.getCalciteRemoveRule()); if (!kylinConfig.isEnumerableRulesEnabled()) { for (RelOptRule rule : CalcitePrepareImpl.ENUMERABLE_RULES) { planner.removeRule(rule); } } // since join is the entry point, we can't push filter past join planner.removeRule(FilterJoinRule.FILTER_ON_JOIN); planner.removeRule(FilterJoinRule.JOIN); // since we don't have statistic of table, the optimization of join is too cost planner.removeRule(JoinCommuteRule.INSTANCE); planner.removeRule(JoinPushThroughJoinRule.LEFT); planner.removeRule(JoinPushThroughJoinRule.RIGHT); // keep tree structure like filter -> aggregation -> project -> join/table scan, implementOLAP() rely on this tree pattern planner.removeRule(AggregateJoinTransposeRule.INSTANCE); planner.removeRule(AggregateProjectMergeRule.INSTANCE); planner.removeRule(FilterProjectTransposeRule.INSTANCE); planner.removeRule(SortJoinTransposeRule.INSTANCE); planner.removeRule(JoinPushExpressionsRule.INSTANCE); planner.removeRule(SortUnionTransposeRule.INSTANCE); planner.removeRule(JoinUnionTransposeRule.LEFT_UNION); planner.removeRule(JoinUnionTransposeRule.RIGHT_UNION); planner.removeRule(AggregateUnionTransposeRule.INSTANCE); planner.removeRule(DateRangeRules.FILTER_INSTANCE); planner.removeRule(SemiJoinRule.JOIN); planner.removeRule(SemiJoinRule.PROJECT); // distinct count will be split into a separated query that is joined with the left query planner.removeRule(AggregateExpandDistinctAggregatesRule.INSTANCE); // see Dec 26th email @ http://mail-archives.apache.org/mod_mbox/calcite-dev/201412.mbox/browser planner.removeRule(ExpandConversionRule.INSTANCE); // KYLIN-4464 do not pushdown sort when there is a window function in projection planner.removeRule(SortProjectTransposeRule.INSTANCE); planner.addRule(KylinSortProjectTransposeRule.INSTANCE); }