rionmonster commented on code in PR #29551:
URL: https://github.com/apache/flink/pull/29551#discussion_r4790402839


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/join/stream/StreamingMultiJoinOperator.java:
##########
@@ -902,6 +907,21 @@ private void handleInsertAfterInput(
     private void addRecordToState(RowData input, @Nullable RowData joinKey, 
int inputId)
             throws Exception {
         final boolean isUpsert = isUpsert(input);
+        // A record that can never match isn't stored. Retractions still go to 
state: removing a
+        // record that was never stored is a no-op, and one stored by an 
earlier version is removed.
+        // Records of inputs with updates without UPDATE_BEFORE or deletes by 
key are always
+        // stored, because their next version or delete is completed from 
state.
+        if (isUpsert
+                && !isUpsertInput[inputId]
+                && !hasKeyOnlyDeletes[inputId]
+                && cannotMatch(input, inputId)) {
+            // Storing an upsert replaces the previous version of the record 
with the same unique
+            // key, which may arrive without UPDATE_BEFORE, so that version is 
removed instead.
+            if (inputSpecs.get(inputId).hasUniqueKey()) {

Review Comment:
   Sure, I've added a note there in both places.



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