buraksenn opened a new pull request, #21220:
URL: https://github.com/apache/datafusion/pull/21220
## Which issue does this PR close?
- Closes #20315.
## Rationale for this change
Issue has details but when we've multiple correlated scalar subqueries
optimizer fails with:
```
Schema error: Ambiguous reference to unqualified field __always_true
```
without the fix:
```
External error: 2 errors in file
/Users/buraksen/d/personal/datafusion2/datafusion/sqllogictest/test_files/subquery.slt
1. query failed: DataFusion error: Optimizer rule 'scalar_subquery_to_join'
failed
caused by
Schema error: Ambiguous reference to unqualified field __always_true
[SQL] SELECT
region,
SUM(duration) as total_duration,
(SELECT COUNT(*) FROM activity WHERE region = a.region) as count,
(SELECT MAX(duration) FROM activity WHERE region = a.region) as
max_duration
FROM activity a
GROUP BY region
at
/Users/buraksen/d/personal/datafusion2/datafusion/sqllogictest/test_files/subquery.slt:1593
2. query failed: DataFusion error: Optimizer rule 'scalar_subquery_to_join'
failed
caused by
Schema error: Ambiguous reference to unqualified field __always_true
[SQL] SELECT region, SUM(duration) as total_duration
FROM activity a
GROUP BY region
HAVING (SELECT COUNT(*) FROM activity WHERE region = a.region) > 1
AND (SELECT MAX(duration) FROM activity WHERE region = a.region) > 20
at
/Users/buraksen/d/personal/datafusion2/datafusion/sqllogictest/test_files/subquery.slt:1620
Error: Execution("2 failures")
error: test failed, to rerun pass `-p datafusion-sqllogictest --test
sqllogictests`
```
This is because we dont alias queries
## What changes are included in this PR?
## Are these changes tested?
added slt tests (I've taken these from the issue repro steps)
## Are there any user-facing changes?
no
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]