korlov42 commented on a change in pull request #9282:
URL: https://github.com/apache/ignite/pull/9282#discussion_r679869486



##########
File path: 
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/PlannerPhase.java
##########
@@ -70,13 +70,70 @@
  */
 public enum PlannerPhase {
     /** */
-    HEURISTIC_OPTIMIZATION("Heuristic optimization phase") {
+    HEP_DECORRELATE("Heuristic phase to decorrelate subqueries") {
         /** {@inheritDoc} */
         @Override public RuleSet getRules(PlanningContext ctx) {
             return RuleSets.ofList(
                 CoreRules.FILTER_SUB_QUERY_TO_CORRELATE,
                 CoreRules.PROJECT_SUB_QUERY_TO_CORRELATE,
-                CoreRules.JOIN_SUB_QUERY_TO_CORRELATE);
+                CoreRules.JOIN_SUB_QUERY_TO_CORRELATE
+            );
+        }
+
+        /** {@inheritDoc} */
+        @Override public Program getProgram(PlanningContext ctx) {
+            return hep(getRules(ctx));
+        }
+    },
+
+    /** */
+    HEP_FILTER_PUSH_DOWN("Heuristic phase to push down filters") {
+        /** {@inheritDoc} */
+        @Override public RuleSet getRules(PlanningContext ctx) {
+            return RuleSets.ofList(
+                CoreRules.FILTER_MERGE,
+                CoreRules.FILTER_AGGREGATE_TRANSPOSE,
+                CoreRules.FILTER_SET_OP_TRANSPOSE,
+                CoreRules.JOIN_CONDITION_PUSH,
+
+                FilterIntoJoinRule.Config.DEFAULT
+                    .withOperandSupplier(b0 ->
+                        b0.operand(LogicalFilter.class).oneInput(b1 ->
+                            
b1.operand(LogicalJoin.class).anyInputs())).toRule(),
+
+                FilterProjectTransposeRule.Config.DEFAULT
+                        .withOperandFor(LogicalFilter.class, f -> true, 
LogicalProject.class, p -> true).toRule()
+            );
+        }
+
+        /** {@inheritDoc} */
+        @Override public Program getProgram(PlanningContext ctx) {
+            return hep(getRules(ctx));
+        }
+    },
+
+    /** */
+    HEP_PROJECT_PUSH_DOWN("Heuristic phase to push down and merge projects") {
+        /** {@inheritDoc} */
+        @Override public RuleSet getRules(PlanningContext ctx) {
+            return RuleSets.ofList(
+                ProjectScanMergeRule.TABLE_SCAN_SKIP_CORRELATED,
+                ProjectScanMergeRule.INDEX_SCAN_SKIP_CORRELATED,
+
+                CoreRules.JOIN_PUSH_EXPRESSIONS,
+
+                ProjectFilterTransposeRule.Config.DEFAULT
+                    .withOperandFor(LogicalProject.class, 
LogicalFilter.class).toRule(),
+
+                ProjectMergeRule.Config.DEFAULT
+                    .withOperandFor(LogicalProject.class).toRule(),
+
+                ProjectRemoveRule.Config.DEFAULT
+                    .withOperandSupplier(b ->
+                        b.operand(LogicalProject.class)
+                            .predicate(ProjectRemoveRule::isTrivial)
+                            .anyInputs()).toRule()

Review comment:
       Good catch! Replaced with core rules for HEP phase.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to