apache / apache/datafusion

Remove duplicated alias in Sort

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

Description

### Describe the bug

```
query TT
explain SELECT count(*) order by count(*);
----
logical_plan
01)Projection: count(*)
02)--Sort: count(Int64(1)) AS count(*) AS count(*) ASC NULLS LAST
03)----Projection: count(Int64(1)) AS count(*), count(Int64(1))
04)------Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
05)--------EmptyRelation
physical_plan
01)ProjectionExec: expr=[1 as count(*)]
02)--PlaceholderRowExec
```

We can see that Sort has two `count(*)`

`Sort: count(Int64(1)) AS count(*) AS count(*) ASC NULLS LAST`

I think ideally we should has single alias

### To Reproduce

_No response_

### Expected behavior

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

No files or tests are named. Start by reproducing the shown EXPLAIN query and trace the logical or physical Sort plan that formats `count(Int64(1)) AS count(*) AS count(*)`; done means the Sort output contains only one `count(*)` alias.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
data, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.