TianJialong opened a new issue, #13724: URL: https://github.com/apache/gluten/issues/13724
### Description ### Summary gluten-flink routes streaming operators to Velox native execution, but legacy group window aggregation (`GROUP BY k, SESSION/TUMBLE/HOP(time, ...)` — the `StreamExecGroupWindowAggregate` node family) has no working native path. This issue tracks executing all three time-window kinds natively, with per-(key, window) accumulators living in the native keyed state backend and watermark-driven emission. ### Current behavior - The `StreamExecGroupWindowAggregate` override cannot produce a correct plan for **any** window kind: the window parameters handed to the plan node are hardcoded placeholders — the slice assigner is built from `0L, 0L, 0L, 1` with `TODO: support more window types`, and the window type / event-time flag are the constants `1` / `true` with `TODO: get from window attributes`. The query's actual SESSION gap, TUMBLE size, and HOP size/slide never reach the native side. - The aggregate call list is dropped: `GroupWindowAggsHandlerNode` is constructed with only the output type, so even a plan that ran would have no aggregates to compute. - `transform.setStateKeySelector(...)` puts the transformation into a Flink keyed state context that the native keyed backend does not share — window queries die at runtime with `Key group not in KeyGroupRange` instead of executing natively. - No fail-loud boundaries: row-count windows (`hasRowIntervalType`), non-default EMIT strategies (early-fire / late-fire / allowed lateness / produce-updates), and processing-time windows all pass plan time and yield broken plans rather than explicit errors. - The Velox side runs the old `GroupWindowAggregator` / `GroupWindowAggsHandler` family, which is a self-declared NYI shell (`GroupWindowAggregator.cpp` aborts with "GroupWindowAggregation is not implemented"). ### Proposal Execute the three legacy time-window kinds natively, matching Flink's `AggregateWindowOperator` semantics: - **Real window parameters in the plan.** The planner derives the window kind (`SESSION` / `TUMBLE` / `HOP`), the session gap, the tumble size, and the hop size+slide from `LogicalWindow` and carries them, plus the aggregate call list and count-star index, through the plan node serde; the key channels/types ride a `KeyedStateSpec` so the user key reaches the native keyed backend without a Flink-side key selector (the transformation stays non-keyed — the `Key group not in KeyGroupRange` class of failure disappears). - **Per-(key, window) native state.** Each distinct (key, window) owns its accumulator row in the native keyed state backend under a `TimeWindow` namespace, so results survive across input batches. - **Window machinery.** SESSION merges in-flight windows per key (per-key actual→state mapping, Flink `MergingWindowSet` semantics) with watermark-driven firing; TUMBLE and HOP take the non-merging path where the window itself is the state namespace — aligned tumble grid, and for HOP every covering `[start, start+size)` window stepping back by slide (legacy `HOP(time, slide, size)` argument order), each overlapping window accumulating independently. The AfterEndOfWindow trigger fires at `maxTimestamp`, late elements are dropped, and empty windows are suppressed at emission. - **Runtime operator.** A `WindowAggOperator` subclass (clone-preserving so the job-offload chain cannot strip it; resolution-style RocksDB rejection failing loud at task initialization; union-list checkpoint state). - **Fail-loud boundaries.** Row-count windows, non-default EMIT strategies, and processing-time windows are rejected at plan time with explicit `VELOX_UNSUPPORTED` errors instead of producing wrong plans. ### Scope and limitations (initial landing) - Event-time windows only; row-count windows and processing-time windows fail loud. - Default EMIT only: INSERT-only output, `allowedLateness = 0`, no update-before, no produce-updates; retract input is rejected (append-only row kinds). - Aggregate functions: `COUNT` and `SUM` are registered under the flinksql namespace with Flink semantics (bare-name overwrite); other aggregates run when their Velox result type already matches the Flink result type, and any mismatch fails loudly at initialization instead of producing wrong values. - HOP windows accumulate into each overlapping window directly; the pane optimization (accumulate once per pane, merge panes at window end) is not attempted. - HEAP keyed backend only; other backends fail loud. We have a working implementation of the above on top of the session-window landing, validated by dual-run tests against native Flink 1.19.2 (changelog-folded exact match on all cases: SESSION p1/p4, a full nexmark q11 run at 2046/2046 rows, TUMBLE, and HOP with overlapping windows) plus planner, runtime-operator, and velox-side unit test suites, and would like to contribute it. ### Gluten version main branch -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
