Hancheng Deng created FLINK-40289:
-------------------------------------

             Summary: Window Top-N examples are not reproducible in streaming 
mode
                 Key: FLINK-40289
                 URL: https://issues.apache.org/jira/browse/FLINK-40289
             Project: Flink
          Issue Type: Improvement
          Components: Documentation, Table SQL / API
    Affects Versions: 2.3.0
            Reporter: Hancheng Deng


h2. Description

The Window Top-N documentation shows six output rows for two 10-minute tumbling 
windows while defining the following watermark:

{code:sql}
WATERMARK FOR bidtime AS bidtime - INTERVAL '1' SECOND
{code}

However, the maximum event time in the displayed input is {{2020-04-15 
08:17:00.000}}. Therefore, in streaming mode, the watermark can advance only to 
approximately {{2020-04-15 08:16:59.000}}.

This closes the {{[08:00, 08:10)}} window, but does not close the {{[08:10, 
08:20)}} window. With an unbounded streaming source and only the displayed 
records, only the first three output rows can be reproduced. The three rows 
shown for the second window are not emitted until later records advance the 
watermark past the window end.

The six displayed rows are valid as final results for bounded/batch input, or 
when subsequent streaming records advance the watermark sufficiently. Neither 
condition is explained in the example.

This issue is present in the Flink 1.20 LTS documentation, the Flink 2.3 stable 
documentation, and the current documentation source.

h2. Affected documentation

* [Flink 1.20 Window 
Top-N|https://nightlies.apache.org/flink/flink-docs-release-1.20/docs/dev/table/sql/queries/window-topn/]
* [Flink 2.3 Window 
Top-N|https://nightlies.apache.org/flink/flink-docs-release-2.3/docs/sql/reference/queries/window-topn/]
* {{docs/content/docs/sql/reference/queries/window-topn.md}}
* {{docs/content.zh/docs/sql/reference/queries/window-topn.md}}

h2. Steps to reproduce

# Use an unbounded streaming source containing only the nine records displayed 
in the documentation.
# Define {{WATERMARK FOR bidtime AS bidtime - INTERVAL '1' SECOND}}.
# Run the documented Window Top-N query.
# Observe that only the Top 3 rows for {{[08:00, 08:10)}} are emitted.
# No rows for {{[08:10, 08:20)}} are emitted because the watermark never 
reaches the end of that window.

h2. Expected documentation improvement

Clarify that the displayed tables represent final results after both windows 
have closed:

* In batch mode, bounded input completion closes the remaining windows.
* In streaming mode, subsequent events must advance the watermark past the 
window end before Window Top-N emits the final result.
* With only the displayed records in an unbounded source, only the first window 
result is emitted.




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to