You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[SPARK-52019][SQL] Strip outer reference before creating a name in toPrettySQL
### What changes were proposed in this pull request?
In the following query we would have `min(outer(t2.t2a))` as a name for `min(t2a)` expression.
```
SELECT t1a
FROM t1
WHERE t1a IN (SELECT t2a
FROM t2
WHERE EXISTS (SELECT min(t2a)
FROM t3))
```
This is a problem in compatibility between single-pass resolver and fixed-point analyzer because names in single-pass are generated after we finish resolution of aggregate expression `min(t2a)` (bottom-up manner) and at that point we have `OuterReference` wrapped around aggregate expression (name looks like `outer(min(t2a))`).
I propose that we fix it in fixed point so we can compute the name in single-pass more easily.
### Why are the changes needed?
To ease development of single-pass analyzer.
### Does this PR introduce _any_ user-facing change?
`Explain extended` of affected plans would be different.
### How was this patch tested?
Existing tests (regenerated golden files).
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes#50804 from mihailoale-db/toprettysqlapichange.
Authored-by: mihailoale-db <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
Copy file name to clipboardExpand all lines: sql/core/src/test/resources/sql-tests/analyzer-results/subquery/negative-cases/invalid-correlation.sql.out
0 commit comments