apache / apache/datafusion

the select clause after union all has many same name columns needn't use different aliases

Open
#10,244 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Is your feature request related to a problem or challenge?

now it reports an error
```sql
> select 1 a,2 b union all select null,null;
Error during planning: Projections require unique expression names but the expression "NULL" at position 0 and "NULL" at position 1 have the same name. Consider aliasing ("AS") one of them.
> select 1 a,2 b union all select 2,2;
Error during planning: Projections require unique expression names but the expression "Int64(2)" at position 0 and "Int64(2)" at position 1 have the same name. Consider aliasing ("AS") one of them.
```

### Describe the solution you'd like

It runs as normal
the result of above query equals to `select 1 a,2 b union all select null,null c` and` select 1 a,2 b union all select 2,2 c`

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the two SQL UNION ALL examples in the issue and inspect the planning path that rejects duplicate expression names. Done means both queries run without requiring aliases and produce the stated results.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
database
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.