Match Flink's legacy window property contract - #24
Conversation
9eaf86b to
43cee05
Compare
|
Reviewed against Flink 2.2's planner/runtime sources. The core contract work checks out — verified against A few things to address or answer before merge: 1. Legacy LTZ 2. Run the upstream Flink suite on this branch and confirm the feature engaged.
3. The TVF path looks exposed to the same LTZ grid divergence — follow-up issue? This PR makes the legacy path stricter than the TVF path: 4. Benchmark edits to pre-existing tests. Changing Nits:
|
|
Hey, thanks for the review. Good catch on the upstream Flink tests and LTZ session behavior. Running Before results: After results: (I as always, encourage running it on your PC cause there is a chance mine is messed up....) For the LTZ sessions point, fixed offsets are safe because they cancel out in gap arithmetic, but DST transitions can change which records merge. Fixed-offset zones remain native, while zones with post-1970 transitions now fall back explicitly. I added parity and fallback coverage and updated the docs. The benchmark sink change was intentional. TVF window properties are I also updated the window-aggregate.md file along side this. Release benchmark results (I encourage you to verify on your machine):
I also fixed the formatting/newline/helper nits. TL;DR:
|
Shape native window results for every legacy property layout before widening planner coverage. Preserve empty-property aggregates, emit rowtime as the final window millisecond, leave proctime as Flink's null marker for outer materialization, and fail loudly on impossible partial layouts.
Flink plans deprecated GROUP BY TUMBLE(...) and GROUP BY HOP(...) queries through a legacy physical node that the existing window-TVF matcher never sees. Route the supported legacy shapes through the same single-phase native window operators, retain the existing SESSION path, and preserve Flink's auxiliary-property and processing-time contracts. Keep semantics the native engine cannot reproduce on Flink with explicit fallback reasons, including row-count windows, updating input, early or late firing, processing-time sessions, and session-zone grids with incompatible local-time assignment. Add parity and fallback coverage for the expanded syntax while leaving legacy table aggregates unsupported. Closes datafusion-contrib#9
Flink shifts TIMESTAMP_LTZ values onto the configured session-zone timeline before assigning legacy session windows. A fixed offset is safe because the same shift applies to every record and cancels out of the session-gap calculation. An offset transition is different: records on opposite sides of a DST boundary can move relative to one another, changing session connectivity and merge results. Keep legacy LTZ sessions native when the zone remains fixed after 1970, and decline to Flink when the zone has later transitions or recurring transition rules. Add parity coverage for a fixed-offset zone, fallback coverage for a DST zone, and document the boundary.
Canonical-state reads and writes temporarily select a synthetic key for each owned key group while storing native partitions in Flink managed state. The previous implementation remembered only the active key and restored it through Flink's normal key-selection path, which hashes the key again. After an initially unset context retained a synthetic partition key, a later checkpoint could rehash that value into a key group outside the subtask's owned range. Preserve and restore the exact active key and key-group pair instead. When the original context was unset, clear the internal key without sending a null key through the RocksDB serializer. Cover consecutive checkpoints on a subtask whose key-group range excludes zero, and document that canonical-state iteration cannot leak its synthetic key into normal keyed execution.
43cee05 to
4fea0c7
Compare
Summary:
This PR adds native coverage for Flink’s deprecated but still widely used GROUP BY TUMBLE(...) and GROUP BY HOP(...) syntax.
Legacy group windows plan as StreamPhysicalGroupWindowAggregate, separately from window TVFs. The new matcher translates supported legacy plans onto StreamFusion’s existing native fixed-window operators. No new Rust operator, JNI interface, physical rel, or exec node is introduced.
Closes #9.
Changes:
Testing
Validated locally with Java 17: