Repository: apache/flink
File: flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/ChangelogNormalizeSemanticTestPrograms.java (Java)

Code before:
                                            Row.ofKind(RowKind.UPDATE_AFTER, "three", 3, "ccc"),
                                            Row.ofKind(RowKind.INSERT, "one", 4, "aaaa"),
                                            Row.ofKind(RowKind.UPDATE_AFTER, "one", 4, "aaaa"),
                                            Row.ofKind(RowKind.INSERT, "two", 1, "d"),
                                            Row.ofKind(RowKind.UPDATE_AFTER, "two", 1, "d"),
                                            Row.ofKind(RowKind.DELETE, "three", 3, "ccc"),
                                            Row.ofKind(RowKind.DELETE, "two", 1, "d"))
                                    .build())
                    .setupTableSink(
                            SinkTestStep.newBuilder("sink_t")
                                    .enforceRetract()
                                    .addSchema(SINK_SCHEMA)
                                    .consumedValues(
                                            "+I[one, 1, a]",
                                            "-U[one, 1, a]",
                                            "+U[one, 2, bb]",
                                            "-U[one, 2, bb]",
                                            "+U[one, 4, aaaa]",
                                            "+I[two, 1, d]",
                                            "-D[two, 1, d]")
                                    .build())
                    .runSql("INSERT INTO sink_t SELECT a, b, c FROM source_t WHERE a <> 'three'")
                    .build();

    static final TableTestProgram UPSERT_SOURCE_WITH_RETRACT_SINK =
            TableTestProgram.of("upsert-with-retract-sink", "validates changelog normalize")
                    .setupTableSource(
                            SourceTestStep.newBuilder("source_t")
                                    .enforceUpsert()
                                    .addSchema(SOURCE_SCHEMA)
                                    .producedValues(
                                            Row.ofKind(RowKind.INSERT, "one", 1, "a"),
                                            Row.ofKind(RowKind.UPDATE_AFTER, "one", 2, "bb"),
                                            Row.ofKind(RowKind.INSERT, "three", 3, "ccc"),
                                            Row.ofKind(RowKind.UPDATE_AFTER, "three", 3, "ccc"),
                                            Row.ofKind(RowKind.INSERT, "one", 4, "aaaa"),
                                            Row.ofKind(RowKind.UPDATE_AFTER, "one", 4, "aaaa"),
                                            Row.ofKind(RowKind.DELETE, "three", 3, "cc"))
                                    .build())
                    .setupTableSink(
                            SinkTestStep.newBuilder("sink_t")
                                    .enforceRetract()
                                    .addSchema(SINK_SCHEMA)
                                    .consumedValues(
                                            "+I[one, 1, a]",
                                            "-U[one, 1, a]",
                                            "+U[one, 2, bb]",
                                            "-U[one, 2, bb]",
                                            "+U[one, 4, aaaa]",
                                            "+I[three, 3, ccc]",
                                            "-D[three, 3, ccc]")

Review comment (suggestion):
update name of this test. all tests use a retract sink now. what is so special about this test compared to others? I guess no filter?
```suggestion
            TableTestProgram.of("upsert-no-filter", "validates changelog normalize")
```

Code after:
    static final TableTestProgram UPSERT_SOURCE_WITH_KEY_FILTER =
            TableTestProgram.of("upsert-with-key-filter", "validates upsert with key filter")
                    .setupTableSource(
                            SourceTestStep.newBuilder("source_t")
                                    .addMode(ChangelogMode.upsert())
                                    .addSchema(SOURCE_SCHEMA)
                                    .producedValues(
                                            Row.ofKind(RowKind.INSERT, "one", 1, "a"),
                                            Row.ofKind(RowKind.UPDATE_AFTER, "one", 2, "bb"),
                                            Row.ofKind(RowKind.UPDATE_AFTER, "three", 3, "ccc"),
                                            Row.ofKind(RowKind.UPDATE_AFTER, "three", 3, "ccc"),
                                            Row.ofKind(RowKind.INSERT, "one", 4, "aaaa"),
                                            Row.ofKind(RowKind.UPDATE_AFTER, "one", 4, "aaaa"),
                                            Row.ofKind(RowKind.INSERT, "two", 1, "d"),
                                            Row.ofKind(RowKind.UPDATE_AFTER, "two", 1, "d"),
                                            Row.ofKind(RowKind.DELETE, "three", 3, "ccc"),
                                            Row.ofKind(RowKind.DELETE, "two", 1, "d"))
                                    .build())
                    .setupTableSink(
                            SinkTestStep.newBuilder("sink_t")
                                    .addMode(ChangelogMode.all())
                                    .addSchema(SINK_SCHEMA)
                                    .consumedValues(
                                            "+I[one, 1, a]",
                                            "-U[one, 1, a]",
                                            "+U[one, 2, bb]",
                                            "-U[one, 2, bb]",
                                            "+U[one, 4, aaaa]",
                                            "+I[two, 1, d]",
                                            "-D[two, 1, d]")
                                    .build())
                    .runSql("INSERT INTO sink_t SELECT a, b, c FROM source_t WHERE a <> 'three'")
                    .build();

    static final TableTestProgram UPSERT_SOURCE_WITH_NO_FILTER =
            TableTestProgram.of("upsert-with-no-filter", "validates upsert with no filter")
                    .setupTableSource(
                            SourceTestStep.newBuilder("source_t")
                                    .addMode(ChangelogMode.upsert())
                                    .addSchema(SOURCE_SCHEMA)
                                    .producedValues(
                                            Row.ofKind(RowKind.INSERT, "one", 1, "a"),
                                            Row.ofKind(RowKind.UPDATE_AFTER, "one", 2, "bb"),
                                            Row.ofKind(RowKind.INSERT, "three", 3, "ccc"),
                                            Row.ofKind(RowKind.UPDATE_AFTER, "three", 3, "ccc"),
                                            Row.ofKind(RowKind.INSERT, "one", 4, "aaaa"),
                                            Row.ofKind(RowKind.UPDATE_AFTER, "one", 4, "aaaa"),
                                            Row.ofKind(RowKind.DELETE, "three", 3, "cc"))
                                    .build())
                    .setupTableSink(
                            SinkTestStep.newBuilder("sink_t")