xiedeyantu commented on code in PR #4354:
URL: https://github.com/apache/calcite/pull/4354#discussion_r2069716538
##########
core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java:
##########
@@ -1227,6 +1227,16 @@ private void substituteSubQuery(Blackboard bb, SubQuery
subQuery) {
// Otherwise, let convertExists translate
// values list into an inline table for the
// reference to Q below.
+ } else if (query instanceof SqlSelect) {
+ // During JOIN ON condition processing, bb.root is
+ // initially null but subquery expansion requires
+ // a non-null bb.root. For IN/NOT IN subqueries
+ // processed via convertExists, we use the join's
+ // left input as bb.root. Exception: in UPDATE queries,
+ // bb.inputs remains null and subquery rewriting is skipped.
+ if (bb.inputs != null && bb.inputs.size() == 2) {
Review Comment:
If the subquery is in `where`, the `inputs` may be a `join`. If the subquery
is in the `on` condition of a `join`, the `inputs` will be `left` and `right`.
The `root` used in the
[register](https://github.com/apache/calcite/blob/1919f8e90305fca997588009bed0ce87ced06011/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java#L1326)
method is `left`.
--
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]