xuzifu666 commented on PR #5354:
URL: https://github.com/apache/calcite/pull/5354#issuecomment-6383450343

   > I’m wondering whether we still need to maintain the expand=true mode. We 
should try to address these issues in expand=false mode wherever possible. The 
issue exposed by the last SQL query in the comments on 
[CALCITE-4340](https://issues.apache.org/jira/browse/CALCITE-4340) is actually 
what [CALCITE-7278](https://issues.apache.org/jira/browse/CALCITE-7278) aims to 
resolve.
   
   Thanks for the suggestion. @iwanttobepowerful 
   I investigated whether the fix can be moved to `expand=false` mode, but 
found it's not currently feasible:
   Under `expand=false`, sub-queries remain as `$SCALAR_QUERY` expressions. The 
decorrelator cannot process them — withDecorrelate(true) on the expand=false 
plan fails to produce a valid result.
   The current fix in convertCorrelatedScalarSubqueryInOn (expand=true path) 
already produces a decorrelation-friendly plan — running with 
withDecorrelate(true) yields an identical plan, confirming the rewrite is what 
the decorrelator expects.
   Making the `expand=false` path work would require enhancing the decorrelator 
/ `SubQueryRemoveRule` to handle $SCALAR_QUERY in ON clauses, which is the 
scope of https://issues.apache.org/jira/browse/CALCITE-7278.
   I'd suggest keeping this fix as a stopgap for the expand=true path (still 
the default) until CALCITE-7278 finished.


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