[ 
https://issues.apache.org/jira/browse/CALCITE-1499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15687506#comment-15687506
 ] 

Maryann Xue commented on CALCITE-1499:
--------------------------------------

I just tried it. Calling "RelOptPlanner.clear()" would do the trick, although a 
fix is needed in "RuleQueue.clear()". It'd make things easier if 
"VolcanoPlanner.clear()" does not clear up the rule set. If that is the case 
(or at least an option), we'd only need one line change in the programs:
{code}
@@ -289,6 +289,7 @@ public static Program standard(RelMetadataProvider 
metadataProvider) {
         new Program() {
           public RelNode run(RelOptPlanner planner, RelNode rel,
               RelTraitSet requiredOutputTraits) {
+            planner.clear();
             final RelNode rootRel2 =
                 rel.getTraitSet().equals(requiredOutputTraits)
                 ? rel
{code}
And the fix in RuleQueue is:
{code}
@@ -144,6 +144,9 @@
   public void clear() {
     this.subsetImportances.clear();
     this.boostedSubsets.clear();
+    for (PhaseMatchList matchList : matchListMap.values()) {
+      matchList.clear();
+    }
   }
 
   /**
{code}

> Add an option to exclude VolcanoPlanner's "originalRoot" from planning process
> ------------------------------------------------------------------------------
>
>                 Key: CALCITE-1499
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1499
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.10.0
>            Reporter: Maryann Xue
>            Assignee: Maryann Xue
>
> The Calcite compilation framework runs a series of Programs for query 
> planning. The default programs consist of some pre-processing HepPrograms, 
> e.g., de-correlation, field-trimming, etc.,  the volcano planning program, 
> and some post-processing HepPrograms. In {{Prepare.optimize()}}, 
> {{planner.setRoot()}} is called before running the programs. As a result, the 
> original rel from sql-to-rel conversion becomes the "originalRoot" in the 
> VolcanoPlanner, and the new rel from the pre-processing programs becomes the 
> new "root". In some cases, we would only want to run volcano planning on the 
> new root based on the assumption that the new root is the desired form after 
> pre-processing. And if we have an option to turn off the planning of the 
> original root, the planning space can be significantly reduced.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to