Referencing a column from `select` and `order by` clauses triggers duplicate expression error
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 344
Description
### Describe the bug
Referencing a column from a certain form of `select` and `order by` clauses causes an error saying "projections require unique expression names".
### To Reproduce
```
> create table foo as values (1, 2), (3, 4), (5, 6);
0 row(s) fetched.
Elapsed 0.002 seconds.
> select cast(column1 as text) from foo order by column1;
Error during planning: Projections require unique expression names but the expression "CAST(foo.column1 AS Utf8)" at position 0 and "foo.column1" at position 1 have the same name. Consider aliasing ("AS") one of them.
```
### Expected behavior
Successful query execution
### Additional context
DataFusion v43.0.0
Contributor guide
Research direction
Start by reproducing the shown SELECT and ORDER BY query against DataFusion v43.0.0, then trace the planner path that handles their projections. Done means the query executes successfully and a regression test covers this case without the duplicate expression error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100