DaZuiZui opened a new pull request, #17843: URL: https://github.com/apache/iotdb/pull/17843
## Description This PR implements Part 1 of #17797 for the table model SQL analyzer. It allows explicit SELECT aliases to be referenced in `GROUP BY` and `ORDER BY`. For example: ```sql SELECT date_bin(1h, time) AS hour_time, AVG(s1) AS avg_s1 FROM table1 GROUP BY hour_time ORDER BY hour_time; ``` The alias is resolved to the original SELECT expression during analysis, so existing semantic checks still apply after alias resolution. ### Name resolution rules This PR follows the name resolution rules discussed in #17797: - `GROUP BY` prefers input columns over SELECT aliases. - `ORDER BY` prefers SELECT aliases over input columns. - Duplicate matching SELECT aliases are rejected with an ambiguity error. ### Scope This PR only handles Part 1 of #17797: - SELECT alias in `GROUP BY` - SELECT alias in `ORDER BY` The following items are intentionally left out of scope for a follow-up PR: - Lateral column alias references in the SELECT list - Alias references in `WHERE` - Alias references in `HAVING` Refs #17797 <hr> This PR has: - [x] been self-reviewed. - [x] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage. <hr> ##### Key changed/added classes (or packages if there are too many classes) in this PR - `StatementAnalyzer` - `SelectAliasReuseTest` - `TestMetadata` ### Test ```bash ./mvnw test -pl iotdb-core/datanode -am -Dtest=SelectAliasReuseTest -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false -DskipITs ``` Result: ```text Tests run: 9, Failures: 0, Errors: 0, Skipped: 0 BUILD SUCCESS ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
