Izeren opened a new pull request, #28858:
URL: https://github.com/apache/flink/pull/28858

   ## What is the purpose of the change
   
   `RangeBoundComparatorCodeGenerator` produces Janino compile errors for 
`RANGE OVER` windows with `TIMESTAMP` ORDER BY columns. Two separate bugs:
   
   1. **(FLINK-25802)** `TIMESTAMP` columns are bound as `BigIntType` but the 
raw `TimestampData` term is passed directly to `ExprCodeGenerator.bindInput()`, 
causing an invalid `(Long) timestampData` cast at runtime.
   
   2. **(FLINK-30499)** `TIMESTAMP_WITH_LOCAL_TIME_ZONE` falls through the 
`case _` default with no special handling, and `ctx.reuseMemberCode()` — which 
contains class-level field declarations generated by `ExprCodeGenerator` — is 
emitted inside the `compare()` method body instead of at class scope, causing a 
Janino compile error for any type that triggers member code generation.
   
   Both bugs surface as:
   
   ```
   InvalidProgramException: Table program cannot be compiled. This is a bug.
     Caused by: CompileException: Cannot cast 
"org.apache.flink.table.data.TimestampData" to "java.lang.Long"
   ```
   
   
   ## Brief change log
   
   - Replace `LogicalTypeRoot` match with `LogicalTypeFamily.TIMESTAMP` / 
`LogicalTypeFamily.TIME` if/else to cover all three TIMESTAMP variants 
uniformly (and remain forward-compatible with future additions)
   - Extract epoch milliseconds via `.getMillisecond()` before passing the 
value to `ExprCodeGenerator.bindInput()`, so the variable type matches the 
declared `BigIntType`
   - Promote child `CodeGeneratorContext` member code to the parent context via 
`addReusableMember()`, placing class-level declarations at class scope rather 
than inside `compare()`
   - Add regression tests in `batch/sql/OverAggregateITCase` for `TIMESTAMP(3)` 
and `TIMESTAMP_LTZ(3)` ORDER BY columns
   
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
   - Added `testRangeOverWithTimestampWithoutTimeZone` and 
`testRangeOverWithTimestampWithLocalTimeZone` to 
`batch/sql/OverAggregateITCase`. Both tests confirm that codegen compiles and 
produces correct window counts for a 10-second RANGE window (reproducing the 
Janino error on the unfixed branch, passing on the fix).
   - All four `OverAggregateITCase` suites pass without regression: `batch/sql` 
(63 tests), `stream/sql` (124 tests), `stream/table` (24 tests).
   
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: no
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): no (codegen 
path only; no per-record overhead)
     - Anything that affects deployment or recovery: no
     - The S3 file system connector: no
   
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (Claude Code)
   
   <!--
   Generated-by: Claude Code
   -->
   


-- 
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]

Reply via email to