twalthr opened a new pull request, #29566:
URL: https://github.com/apache/flink/pull/29566

   ## What is the purpose of the change
   
   Process table functions with a custom `TypeInference` can declare several 
state entries via `StateTypeStrategy`. Until now, every declared entry had to 
be inferable: a `StateTypeStrategy#inferType` returning `Optional.empty()` 
failed planning with "Could not infer a data type for state entry '...'".
   
   This PR gives `Optional.empty()` a meaning for process table functions: the 
state entry is not used by this call. A function can therefore declare a 
superset of state entries and let the type inference decide which ones a 
specific call needs, with matching `eval()` / `onTimer()` overloads.
   
   ## Brief change log
   
     - `TypeInferenceUtil#inferStateInfos` excludes state entries whose 
`StateTypeStrategy` returns `Optional.empty()`. `ProcessTableRunnerGenerator` 
and `StreamExecProcessTableFunction` derive state positions and names from the 
resulting map, so `eval()` / `onTimer()` resolve to the overload without a 
parameter for the excluded entry.
     - An empty accumulator (`acc`) of aggregating functions and an untyped 
`NULL` still fail with a `ValidationException`.
     - `StateTypeStrategy` explicitly overrides `inferType` and documents the 
semantics for PTFs and aggregating functions.
     - `ProcessTableFunctionTestHarness` skips excluded state entries instead 
of throwing.
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - Added `process-optional-state` to `ProcessTableFunctionSemanticTests`. 
It calls one PTF twice in a `UNION ALL` (different `uid`s). The PTF declares 
two state entries, and its type inference excludes the second one for `mode => 
1`. It has two `eval()` and two `onTimer()` overloads, each pair covering one 
of the two calls.
     - Added 
`ProcessTableFunctionTestHarnessTest#testStateEntryExcludedByTypeInference`. It 
fails without the harness change with `Could not infer data type for state 
parameter 'unused'`.
   
   ## 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)`: yes (`StateTypeStrategy` is `@PublicEvolving`; only the 
meaning of an empty result changes, no signature changes)
     - 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
     - If yes, how is the feature documented? JavaDocs
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (claude-sonnet-5-5)
   


-- 
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]

Reply via email to