joooger opened a new pull request, #5332:
URL: https://github.com/apache/calcite/pull/5332

   Jira: https://issues.apache.org/jira/browse/CALCITE-7859
   
   `SqlToRelConverter.convertMerge` assumes that the input of the projection of 
the MERGE source select is the join of the source and the target. With `expand 
= true` a sub-query in a `SET` expression is expanded into a join or a 
correlate on top of that join, which breaks the assumption:
   
   * a correlated sub-query fails with `ClassCastException: LogicalCorrelate 
cannot be cast to LogicalJoin`;
   * an uncorrelated sub-query is converted into a wrong plan: the number of 
source fields is taken from the wrong join, so the target columns are dropped 
from the update row (`LogicalProject(EXPR$0=[$18])` instead of the 9 target 
columns followed by `EXPR$0`).
   
   Changes:
   * take the number of source fields from the validator namespace of the 
source table reference;
   * build the new projection over the real input of the source projection 
instead of the first join;
   * add `testMergeUpdateCorrelatedSubQueryExpanded` and 
`testMergeUpdateUncorrelatedSubQueryExpanded`.
   


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