JackieTien97 opened a new pull request, #18749: URL: https://github.com/apache/iotdb/pull/18749
## Description Distributed TVF queries can violate an explicit `ORDER BY`: the TVF clears the scan ordering requirement, but a later scan-based optimization can still remove the sort. This allows `TESL` rows to precede `AAPL` rows in the [failing window TVF CI job](https://github.com/apache/iotdb/actions/runs/36408567743/job/108883043075). - Push ordering through pass-through columns of the known order-preserving `TUMBLE`, `HOP` and `CUMULATE` implementations, and propagate each distributed child's proven ordering. Other TVFs expose at most a proven partition-key ordering; a custom row-semantic processor may buffer and reorder its output. - Retain sorting for function-produced columns. Expanding an input row means that all TAGs plus TIME no longer uniquely identify a result row. Keep `StreamSort` only when its input has the required ordered prefix; otherwise use `Sort`. - Avoid introducing `MergeSort` solely to combine TVF outputs when no parent requests ordering. Window-function IT assertions also gain complete output ordering. Only positional ROWS windows, `ROW_NUMBER` and `NTILE` add an input time tie-breaker; peer-based ranking and RANGE/GROUPS semantics and all expected results remain unchanged. ## Validation - Full English reactor: `mvn clean test -Dtest=TableFunctionSortTest,TableFunctionTest,SortTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false` — 41 tests passed. - Full Chinese reactor: `mvn test-compile -DskipTests -Pwith-zh-locale` — passed. - Combined Java 17 / `TableClusterIT` clean verification — 60 tests passed. Covers both ordinary and SHUFFLE partitioning: all methods in `IoTDBWindowFunctionIT` and `IoTDBWindowFunction2IT`, plus HOP, TUMBLE, CUMULATE and CAPACITY methods in both window TVF classes. - Spotless applied; Checkstyle and RAT enabled. Local RAT runs exclude five pre-existing, untracked SVG assets, with no additional tracked-source exclusions. This PR has: - [x] been self-reviewed. - [x] added comments explaining the ordering guarantees and optimization boundaries. - [x] added planner regression tests and updated integration assertions. - [x] passed the final combined cluster regression. ### Key changed classes `TableFunctionOrdering`, `TableDistributedPlanGenerator`, `TransformSortToStreamSort`, `SortElimination`, `IoTDBWindowTVFIT`, and `IoTDBWindowFunctionIT`. -- 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]
