kalayciburak opened a new pull request, #5293: URL: https://github.com/apache/calcite/pull/5293
## Jira Link [CALCITE-7822](https://issues.apache.org/jira/browse/CALCITE-7822) ## Changes Proposed A RANGE window without ORDER BY takes an implicit sort key from the FROM item's monotonic column. After GROUP BY that column is no longer an input, but its original ordinal was still turned into a RexInputRef. `Project.isValid` then failed, for example `SMALLINT NOT NULL` (EMPNO) versus `TINYINT` (DEPTNO). The converted key is kept when its input refs match the current input. Otherwise a simple column is rebound by name, or dropped if GROUP BY removed it. Unbounded RANGE already allows an empty order list. `select deptno, count(*) over () as c from emp group by deptno` on the scott schema now returns `DEPTNO=10/20/30` with `C=3`. The same shape with an explicit RANGE frame and `max(max(sal)) over ()` grouped by job also converts. ROWS framing, an explicit ORDER BY, and GROUP BY of the monotonic column itself are unchanged. ## Tests - `JAVA_HOME=21 ./gradlew :core:test --tests org.apache.calcite.test.JdbcTest.testEmptyOverInAggregateQuery` — failed before the fix with `AssertionError: type mismatch: ref: SMALLINT NOT NULL input: TINYINT`; passed after - `./gradlew :core:test --tests org.apache.calcite.test.JdbcTest.testWin* --tests org.apache.calcite.test.JdbcTest.testOver* --tests org.apache.calcite.test.SqlToRelConverterTest.testWindow* --tests org.apache.calcite.test.SqlToRelConverterTest.testOver*` — 39 completed, 0 failed - `./gradlew :core:checkstyleMain :core:checkstyleTest` — passed -- 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]
