[FLINK-40423][python] Add Top-N support to the DataFrame API - #29105
Open
Timm0 wants to merge 1 commit into
Open
[FLINK-40423][python] Add Top-N support to the DataFrame API#29105Timm0 wants to merge 1 commit into
Timm0 wants to merge 1 commit into
Conversation
- Add `DataFrame.top_n` - Generalize `_build_deduplication_query` into the shared `_build_rank_sql` - Route `drop_duplicates` through `_build_rank_sql` - Add `_normalize_descending` helper - Move `_materialize` test helper to `PyFlinkStreamDataFrameTestCase` - Add `DataFrameTopNTests` + `DataFrameTopNITTests` - List `DataFrame.top_n` in the API reference
Timm0
marked this pull request as ready for review
September 4, 2026 14:30
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
This change adds
DataFrame.top_n(...)for global and per-group Top-N, and refactors the existingdrop_duplicatesonto the same shared SQL builder so both produce the same plan (StreamPhysicalRank, orStreamPhysicalDeduplicateforn == 1on a time attribute).Brief change log
DataFrame.top_n_build_deduplication_queryinto the shared_build_rank_sqldrop_duplicatesthrough_build_rank_sql_normalize_descendinghelper_materializetest helper toPyFlinkStreamDataFrameTestCaseDataFrameTopNTests+DataFrameTopNITTestsDataFrame.top_nin the API referenceVerifying this change
DataFrameTopNTestsDataFrameTopNITTestsDoes this pull request potentially affect one of the following parts:
@Public(Evolving): yesDocumentation
flink-python/docs/reference/pyflink.dataframe/dataframe.rst+ Python docstringsWas generative AI tooling used to co-author this PR?
Generated-by: Opus 4.8 (1M context)