zzwqqq commented on code in PR #5385:
URL: https://github.com/apache/calcite/pull/5385#discussion_r4504890402


##########
core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java:
##########
@@ -464,9 +497,48 @@ public RelNode removeCorrelationViaRule(RelNode root) {
    * {@link org.apache.calcite.rel.core.Correlate}s might be removable in such 
way).
    */
   public RelNode removeCorrelationViaRule(RelNode root, RuleSet ruleSet) {
+    root = prepareCorrelates(root);
     return applyHepProgram(root, ruleSetToHepProgram(ruleSet));
   }
 
+  /** Removes unused RHS computations before matching rules or building frames.
+   * The checked input must also be the input used by the rewrite.
+   */
+  private RelNode prepareCorrelates(RelNode root) {
+    final RelNode prepared = root.accept(new RelHomogeneousShuttle() {

Review Comment:
   Thanks. I've removed the preparation shuttle. The scalar rules and general 
rewrite now trim their right inputs locally.



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