gustavodemorais commented on code in PR #30182:
URL: https://github.com/apache/flink/pull/30182#discussion_r4772525037


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/DeduplicateTestPrograms.java:
##########
@@ -248,6 +250,184 @@ public class DeduplicateTestPrograms {
                                     + "keep => 'last')")
                     .build();
 
+    public static final TableTestProgram UPDATING_INPUT =
+            TableTestProgram.of(
+                            "deduplicate-updating-input",
+                            "with one live row per key, every change is 
forwarded whatever "
+                                    + "keep and sequence_by say, a key-only -D 
is emitted with the "
+                                    + "full row, a -D without state emits 
nothing, and +U without "
+                                    + "state is a first record")
+                    .setupTableSource(
+                            SourceTestStep.newBuilder("customers_cdc")
+                                    .addSchema(
+                                            "customer_id STRING PRIMARY KEY 
NOT ENFORCED",
+                                            "city STRING",
+                                            "lsn BIGINT")
+                                    .addMode(ChangelogMode.upsert())
+                                    .producedValues(
+                                            Row.ofKind(RowKind.INSERT, "c1", 
"Berlin", 100L),
+                                            Row.ofKind(RowKind.UPDATE_AFTER, 
"c1", "Munich", 120L),
+                                            Row.ofKind(RowKind.UPDATE_AFTER, 
"c1", "Hamburg", 110L),
+                                            Row.ofKind(RowKind.DELETE, "c1", 
null, null),
+                                            Row.ofKind(RowKind.DELETE, "c1", 
null, null),
+                                            Row.ofKind(RowKind.UPDATE_AFTER, 
"c1", "Bremen", 115L))
+                                    .build())
+                    .setupTableSink(
+                            SinkTestStep.newBuilder("sink")
+                                    .addSchema(
+                                            "customer_id STRING PRIMARY KEY 
NOT ENFORCED",
+                                            "city STRING",
+                                            "lsn BIGINT")
+                                    .consumedValues(
+                                            "+I[c1, Berlin, 100]",
+                                            "+U[c1, Munich, 120]",
+                                            "+U[c1, Hamburg, 110]",
+                                            "-D[c1, Hamburg, 110]",
+                                            "+I[c1, Bremen, 115]")
+                                    .build())
+                    .setupTableSink(
+                            SinkTestStep.newBuilder("sink_first")
+                                    .addSchema(
+                                            "customer_id STRING PRIMARY KEY 
NOT ENFORCED",
+                                            "city STRING",
+                                            "lsn BIGINT")
+                                    .consumedValues(
+                                            "+I[c1, Berlin, 100]",
+                                            "+U[c1, Munich, 120]",
+                                            "+U[c1, Hamburg, 110]",
+                                            "-D[c1, Hamburg, 110]",
+                                            "+I[c1, Bremen, 115]")
+                                    .build())
+                    .runSql(
+                            "INSERT INTO sink SELECT * FROM DEDUPLICATE("
+                                    + "input => TABLE customers_cdc PARTITION 
BY customer_id, "
+                                    + "keep => 'last', "
+                                    + "sequence_by => DESCRIPTOR(lsn))")
+                    .runSql(
+                            "INSERT INTO sink_first SELECT * FROM DEDUPLICATE("
+                                    + "input => TABLE customers_cdc PARTITION 
BY customer_id, "
+                                    + "keep => 'first')")
+                    .build();
+
+    public static final TableTestProgram RETRACT_INPUT =
+            TableTestProgram.of(
+                            "deduplicate-retract-input",
+                            "on retract input partitioned by its upsert key, 
an update "
+                                    + "replaces the kept row")

Review Comment:
   The planner drops the -U before the PTF here, since `PARTITION BY` is the 
primary key, so this is the case where every change is forwarded as is:
   ```suggestion
                               "on retract input partitioned by its upsert key, 
the planner drops "
                                       + "the -U before the PTF, so every 
change is forwarded as is")
   ```



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