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

   ## What is the purpose of the change
   
   `DEDUPLICATE` now accepts updating input. For each `PARTITION BY` key it 
returns the first or last of the key's live rows, the same as running the query 
in batch on the current input table. `sequence_by` orders different rows, never 
versions of the same row, since the changelog already defines the versions.
   
   This follows the approach agreed on FLINK-41472 and differs from FLIP-622 
§4.1.4.5 (dropping out-of-order CDC versions) and §7 (rejecting several live 
rows per key). The FLIP page will be updated to match.
   
   ## Brief change log
   
   `Deduplicate#specialize` picks the implementation from the input's changelog 
mode and upsert keys:
     - Insert-only input: unchanged.
     - `PARTITION BY` equals an upsert key of the input, so a key has at most 
one live row: `DeduplicatePassThroughFunction` forwards every change without 
state, or `DeduplicateKeyedRowFunction` keeps the current row when the output 
needs `-U` that the input does not carry.
     - Any other updating input: `DeduplicateLiveRowsFunction` keeps the key's 
live rows in a `MapView` (row -> count, arrival) plus the kept row. A 
retraction of the kept row falls back to the best remaining row, or emits `-D` 
if none is left. Without `sequence_by`, a per-key arrival counter orders the 
rows.
     - `DeduplicateDefinition`: the input table supports updates, and the 
output contains `DELETE` when the input can retract rows.
     - With `state_ttl`, expired live rows are no longer candidates. The kept 
row is refreshed by every record of its key, so the output never loses the row 
it last emitted.
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
     - `DeduplicateSemanticTests`: upsert input with one live row per key 
(`UPDATING_INPUT`, `UPDATING_INPUT_KEEP_FIRST`, `RETRACT_INPUT`), and several 
live rows per key with fallback, `-D` of the last row, and a duplicate row 
keeping its earliest arrival with `keep => 'first'` (`LIVE_ROWS`).
     - `DeduplicateHarnessTest`: three state TTL cases for several live rows 
per key, with a manually set TTL clock: the kept row's entry expiring before 
the kept row, the arrival counter expiring while rows remain, and a retraction 
keeping the kept row alive.
     - All existing `DEDUPLICATE` planner tests pass.
   
   ## 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): yes. New 
runtime functions for updating input. With several live rows per key, a 
retraction of the kept row scans the key's live rows.
     - 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? docs
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (Claude Opus 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