Skip to content

[FLINK-40179] Support windowed states in state catalog - #29011

Open
gyfora wants to merge 3 commits into
apache:masterfrom
gyfora:state-catalog-contrib-2
Open

[FLINK-40179] Support windowed states in state catalog#29011
gyfora wants to merge 3 commits into
apache:masterfrom
gyfora:state-catalog-contrib-2

Conversation

@gyfora

@gyfora gyfora commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of the change

This is the second part of the code contribution for the FLIP-599 State Catalog

The StateCatalog can already expose plain keyed state from a savepoint as queryable tables. This PR extends that support to namespaced keyed state — most commonly window state — so state kept per (key, window) pair can also be discovered and queried as a table through the StateCatalog, instead of only being reachable via the lower-level SavepointReader API.

Brief change log

  • Added the schema-extraction and table-building utilities needed to describe namespaced keyed state as a catalog table, mirroring the existing
    utilities for plain keyed state.
  • Wired the new window tables into StateCatalog and SavepointDynamicTableSourceFactory, adding two new table shapes: simple keyed window table, flattened window table (similar to keyed states)
  • Added the readers/operators needed to pull namespaced state out of a savepoint and feed it into these tables
  • Fixed a bug in SavepointEnvironment#getTaskInfo where the reported number of subtasks could exceed the max parallelism of the operator being read. This surfaces when reading state from operators with a low max parallelism, such as windowAll().
  • Added integration tests covering both the general and flattened window tables end to end, through the catalog and via SQL

Verifying this change

  • Added StateCatalogWindowITCase which builds real savepoints containing window state and verifies both
    catalog discovery and SQL reads for the new tables.
  • Added a unit test for the new window state reader function.
  • Existing keyed-state catalog/table tests continue to pass, confirming the plain keyed-state path is unaffected.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving):no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? not yet

Was generative AI tooling used to co-author this PR?
  • [x ] Yes

Generated-by: Claude Sonnet 5

gyfora added 3 commits August 24, 2026 13:35
…ties

Adds the schema-extraction and catalog-table-building utilities needed
to expose namespaced (e.g. window-scoped) keyed state: getWindowKeyedStateSchema,
getWindowStateCatalogTable, and getFlattenedWindowStateCatalogTable in
StateTableUtils, mirroring the plain keyed state utilities added
previously. These are not yet wired into the catalog or table factory.
…d factories

Wires namespaced (e.g. window-scoped) keyed state into the StateCatalog
and SavepointDynamicTableSourceFactory: StateCatalog#getTable/tableName/
candidateTablesForOperator now handle StateReaderMode.WINDOWED/
WINDOWED_FLAT alongside the existing KEYED/KEYED_FLAT tables, and
SavepointDynamicTableSourceFactory gains createWindowDynamicTableSource/
createFlattenedWindowDynamicTableSource dispatch.

Adds the supporting implementation: WindowStateTableMapping,
WindowFlattenedStateTableMapping, WindowKeyedStateReader,
WindowFlattenedKeyedStateReader, WindowSavepointDataStreamScanProvider,
WindowFlattenedSavepointDataStreamScanProvider,
WindowKeyedStateReaderFunction, WindowKeyedStateReaderOperator, and
MultiStateKeyAndNamespaceIterator, plus SavepointReader#readWindowKeyedState
for programmatic access to namespaced keyed state.

Non-keyed/operator state support (LIST/UNION/BROADCAST) is deferred to a
later commit.
Adds StateCatalogWindowITCase covering read access to namespaced (e.g.
window-scoped) keyed state through the StateCatalog, including the
flattened LIST/MAP variant.

Fixes SavepointEnvironment#getTaskInfo to cap the reported
numberOfParallelSubtasks at the being-read operator's maxParallelism:
the wrapping read job's own parallelism is unrelated to the source
operator's savepoint maxParallelism and may exceed it (e.g. a
windowAll()/forceNonParallel() operator has maxParallelism == 1),
which otherwise violates TaskInfoImpl's invariant that
maxParallelism >= numberOfParallelSubtasks.
@gyfora
gyfora requested a review from gaborgsomogyi August 24, 2026 12:43
@flinkbot

flinkbot commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants