DaZuiZui opened a new pull request, #17706: URL: https://github.com/apache/iotdb/pull/17706
## Description This PR fixes incorrect window function results when multiple `RANK()` expressions with different `ORDER BY` clauses are planned together and some window input symbols come through identity projections. ### Fix window ordering symbol remapping `GatherAndMergeWindows` now keeps each window node's ordering scheme aligned with the symbols produced by the merged child. When the rule merges windows across identity projections, it remaps the ordering keys instead of reusing stale symbols from the original node. This prevents a preceding window, such as `RANK() OVER (ORDER BY time)`, from affecting the ordering used by following rank functions. ### Cover abnormal window ranking cases Added integration tests for the reported table-model cases, including: - a leading `RANK() OVER (ORDER BY time)` followed by rank functions over other columns - mixed ascending and descending ordering keys - `ma_3`, `ma_13`, and `ma_120` ranking cases where following ranks previously matched the first rank unexpectedly - tie handling for `RANK()` results Fixes #17635 <hr> This PR has: - [x] been self-reviewed. - [x] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader. - [x] added integration tests. - [x] been tested in a test IoTDB cluster. Tested with: - `./mvnw clean package -P with-integration-tests -DskipTests -ntp` - `./mvnw clean package -pl distribution -am -DskipTests -ntp` - `./mvnw clean verify -DskipUTs -Dit.test=IoTDBWindowFunction3IT -DfailIfNoTests=false -Dfailsafe.failIfNoSpecifiedTests=false -pl integration-test -am -PTableSimpleIT -P with-integration-tests -ntp` - `./mvnw clean verify -DskipUTs -Dit.test=IoTDBWindowFunction3IT#* -DfailIfNoTests=false -Dfailsafe.failIfNoSpecifiedTests=false -pl integration-test -am -PTableSimpleIT -P with-integration-tests -ntp` - local manual table-model CLI verification on a rebuilt standalone IoTDB distribution <hr> ##### Key changed/added classes (or packages if there are too many classes) in this PR - `org.apache.iotdb.db.queryengine.plan.relational.planner.iterative.rule.GatherAndMergeWindows` - `org.apache.iotdb.relational.it.db.it.IoTDBWindowFunction3IT` -- 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]
