AnissaLiu opened a new issue, #13687:
URL: https://github.com/apache/gluten/issues/13687

   ### Description
   
   **Description**:
   
   Streaming window TVF aggregation is currently rejected at plan translation 
in the Flink (gluten-flink) stateful execution line. Queries of the form
   
   ```sql
   SELECT key, window_start, window_end, COUNT(*), SUM(x)
   FROM TABLE(TUMBLE(TABLE src, DESCRIPTOR(ts), INTERVAL '5' SECOND))
   GROUP BY key, window_start, window_end;
   ```
   
   (and the HOP / SESSION variants) cannot run on the native stateful backend 
today.
   
   We propose full support, aligned with Flink 1.19 semantics:
   
   - Single-stage window aggregation translated natively (planner passes 
`KeyedStateSpec`, `shiftTimeZone`, real window-column positions; keyless 
windows via a wrapped constant `$keyless_key` channel; FILTER masks supported; 
update-stream input rejected with an explicit error).
   - Two-stage local–global execution mirroring Flink's 
`TwoStageOptimizedWindowAggregateRule` / `LocalSlicingWindowAggOperator` / 
`SliceAttachedWindowingStrategy`: the local stage pre-aggregates per (key, 
sliceEnd) into in-memory accumulators and flushes partial rows `[keys, 
intermediates, windowEnd(BIGINT)]` **before** forwarding the watermark; the 
global stage consumes them at a `kFinal` aggregation step whose slice end comes 
directly from the trailing windowEnd column. Output row layouts follow Flink's 
`deriveLocalWindowAggregateRowType` / `deriveWindowAggregateRowType` verbatim.
   - Scope of the two-stage path matches Flink's rule: event-time, non-SESSION 
windows (TUMBLE/HOP; CUMULATE to follow later). SESSION and processing-time 
windows run single-stage.
   - Companion operator implementation in the velox stateful framework and 
plan-node serde in velox4j (PRs to those repos follow separately).
   
   Verified against native Flink 1.19.2 (same-input double-run, multiset-exact 
comparison): single-stage 8/8 scenarios exact match, two-stage 7/7 exact match, 
SESSION gap-merge match plus a nexmark 10M-event closure of exactly 8,900,000. 
Performance on 100M events (blackhole, parallelism 4, same-day native 
references): nexmark q12 16.4–16.9s vs native 82.9s (object-reuse off) / 41.4s 
(on); HOP 30s/5s 50.3–52.0s single-stage (53.1–53.6s two-stage) vs native 
two-phase 73.4s; SESSION gap 30s 19.2–19.5s vs native 71.5s (off) / 40.9s (on).
   
   ### 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]

Reply via email to