If group by key contains constant columns, the constant columns should be removed from group by key
Open
sig/planner
type/enhancement
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Enhancement
Consider the following cases
```
1. select count(*), id from test where id = 1 group by id
2. select count(*), id, value from test where id = 1 group by id, value
```
If there is no implict cast in expr `id = 1`, then `id` should be a constant column after filter, it can be removed from the group by keys, that is the optimizer should rewrite the sql to
```
1. select count(*), first_row(id) from test where id = 1
2. select count(*), first_row(id), value from test where id = 1 group by value
```
Contributor guide
Assessment
This issue has not been assessed yet.