juntaozhang commented on code in PR #4338:
URL: https://github.com/apache/calcite/pull/4338#discussion_r2062586723


##########
core/src/main/java/org/apache/calcite/rel/rules/SortJoinTransposeRule.java:
##########
@@ -116,13 +121,26 @@ public SortJoinTransposeRule(Class<? extends Sort> 
sortClass,
               mq, join.getLeft(), joinInfo.leftSet())) {
         return false;
       }
+      if (alreadyPushedDown(join.getRight())) {
+        return false;
+      }
     } else {
       return false;
     }
 
     return true;
   }
 
+  // Returns true if the sort has already been pushed down
+  private boolean alreadyPushedDown(RelNode rel) {

Review Comment:
   I'm very glad that you can review this PR. Your two questions seem to be 
answered in 
`testSortJoinTranspose6`[CALCITE-1507](https://issues.apache.org/jira/browse/CALCITE-1507),
 it explains when pushing down has no impact. This PR fix if the pushdown 
succeeds, under certain rules, it could enter a loop of transpositions, leading 
to a stack overflow. 



-- 
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