Izeren opened a new pull request, #28967:
URL: https://github.com/apache/flink/pull/28967
Backport of #28858 to release-2.3.
## What is the purpose of the change
`RangeBoundComparatorCodeGenerator` compared TIMESTAMP values using
`.getMillisecond()`, which truncates sub-millisecond precision. For TIMESTAMP(n
> 3) columns, two timestamps that differ only in microseconds were treated as
equal, causing incorrect RANGE OVER window boundaries.
The fix converts both the bound and the input/current row values to epoch
microseconds (`millis * 1000L + nanoOfMillis / 1000`) before comparison,
preserving up to microsecond precision without risking Long overflow
(nanoseconds would overflow at ~year 2262).
## Brief change log
- `RangeBoundComparatorCodeGenerator`: scale millisecond bound by 1000 to
microseconds; derive epoch-microsecond values from `getMillisecond() * 1000L +
getNanoOfMillisecond() / 1000`
- Added `OVER_AGGREGATE_RANGE_TIMESTAMP` and
`OVER_AGGREGATE_RANGE_TIMESTAMP_LTZ` test programs to
`OverAggregateBatchRestoreTest` (upgraded to TIMESTAMP(6) with a
sub-millisecond row that validates the range boundary is exclusive)
## Verifying this change
This change added tests and can be verified as follows:
- Added `OVER_AGGREGATE_RANGE_TIMESTAMP` (TIMESTAMP(6) with
sub-millisecond boundary row) and `OVER_AGGREGATE_RANGE_TIMESTAMP_LTZ` programs
to `OverAggregateBatchRestoreTest`, which verifies both execution correctness
and plan JSON round-trip via `BatchRestoreTestBase`
## 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): yes (RANGE
OVER codegen path, bug fix only)
- 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]