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

   ## What is the purpose of the change
   
   In batch mode, a pandas UDAF over a RANGE window with a `CURRENT ROW` or `n 
PRECEDING/FOLLOWING` bound found its frame by reading the ORDER BY key as 
TIMESTAMP(3) 
([FLINK-41294](https://issues.apache.org/jira/browse/FLINK-41294)). INT and 
DECIMAL keys got wrong frames, and a DECIMAL offset such as `2.5 PRECEDING` 
failed in the planner with a `ClassCastException`. This makes the operator find 
the frame bounds with the same generated range-bound comparators as the native 
batch over aggregate.
   
   ## Brief change log
   
     - `BatchExecOverAggregate#createBoundComparator` becomes a package-private 
static helper (first commit, no behavior change).
     - `BatchExecPythonOverAggregate` uses it to create a bound comparator for 
each bounded side of a RANGE window and passes them to the operator. RANGE 
offsets are no longer cast to `long`. The sort key is also no longer read for 
windows without ORDER BY, where it failed with an 
`ArrayIndexOutOfBoundsException`.
     - `BatchArrowPythonOverWindowAggregateFunctionOperator` moves the frame 
boundaries with those comparators instead of TIMESTAMP(3) arithmetic. As in 
`RangeSlidingOverFrame`, the lower boundary doesn't move past the upper one or 
the end of the partition.
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - `BatchPandasUDAFITTests#test_over_window_range_frame_with_int_order_key` 
and `#test_over_window_range_frame_with_decimal_order_key` check that the 
pandas UDAF sees the same frames as the native `COUNT` for INT and DECIMAL(10, 
2) keys, including a DECIMAL offset and a FOLLOWING lower bound.
     - `#test_over_window_range_frame_after_null_order_key` checks a FOLLOWING 
frame after a NULL key.
     - 
`BatchArrowPythonOverWindowAggregateFunctionOperatorTest#testRangeWindowOnIntOrderKey`
 checks the frame starts for an INT key with negative values.
   
   ## 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
     - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
     - If yes, how is the feature documented? not applicable
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code 2.1.321 (Claude Opus 5.5)
   


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