Consider not performing alias rewrite to the rest of the query when alias is a column name
- Dominant language
- Java
- Stars
- 6.1k
- Forks
- 1.5k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 189
Description
E.g. `SELECT SUM(a) AS a WHERE a > 10` will throw exception because it will be rewritten to `SELECT SUM(a) AS a WHERE SUM(A) > 10`
Also, seems alias is not allowed in `WHERE` clause in standard SQL: https://docs.oracle.com/cd/E17952_01/mysql-5.7-en/problems-with-alias.html.
Not sure if we should block alias rewrite in `WHERE` clause because it can cause backward incompatible.
Contributor guide
Research direction
Start by reproducing the `SELECT SUM(a) AS a WHERE a > 10` query and tracing Pinot's alias-rewrite entry point. Investigate how alias references in `WHERE` are distinguished from column references, then clarify the compatibility decision and add regression coverage for the chosen behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100