charles-paperman opened a new issue, #27535:
URL: https://github.com/apache/datafusion/issues/27535
### Describe the bug
Distinct calls to the same table function can be incorrectly deduplicated in
scalar subqueries, causing one result to be reused for both columns.
### Additional observations
- The same issue occurs with `range(1, 2)` and `range(2, 3)`.
- Reversing the subqueries returns `(2, 2)`.
- `EXPLAIN` shows a single scalar subquery reused for both columns.
- Giving the table-function calls distinct table aliases restores the
correct result.
### Workaround
The following setting also restores the correct result for these
reproducers:
```sql
SET datafusion.optimizer.enable_physical_uncorrelated_scalar_subquery =
false;
```
### To Reproduce
```sql
SELECT
(SELECT * FROM generate_series(1, 1)) AS first,
(SELECT * FROM generate_series(2, 2)) AS second;
```
**GOT:** `(1, 1)`
### Expected behavior
```sql
SELECT
(SELECT * FROM generate_series(1, 1)) AS first,
(SELECT * FROM generate_series(2, 2)) AS second;
```
**SHOULD BE:** `(1, 2)`
### Additional context
- The same issue occurs with `range(1, 2)` and `range(2, 3)`.
- Reversing the subqueries returns `(2, 2)`.
- `EXPLAIN` shows a single scalar subquery reused for both columns.
- Giving the table-function calls distinct table aliases restores the
correct result.
```SQL
SET datafusion.optimizer.enable_physical_uncorrelated_scalar_subquery =
false;
``
### Willingness to contribute
I would like to contribute a fix for this bug, but request guidance from the
DataFusion community
--
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]