gustavodemorais commented on code in PR #30123:
URL: https://github.com/apache/flink/pull/30123#discussion_r4718578294
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/StaticArgumentTrait.java:
##########
@@ -57,18 +57,22 @@ public enum StaticArgumentTrait {
// For SET_SEMANTIC_TABLE
OPTIONAL_PARTITION_BY(SET_SEMANTIC_TABLE),
- /**
- * Specifies that the table argument rejects an ORDER BY clause, for a
function that orders
- * records by an argument of its own. Reserved for built-in functions.
- */
- NO_ORDER_BY(SET_SEMANTIC_TABLE),
-
// For BROADCAST_SEMANTIC_TABLE
NOTIFY_STATEFUL_SETS(BROADCAST_SEMANTIC_TABLE),
// For SUPPORT_UPDATES
REQUIRE_UPDATE_BEFORE(SUPPORT_UPDATES),
- REQUIRE_FULL_DELETE(SUPPORT_UPDATES);
+ REQUIRE_FULL_DELETE(SUPPORT_UPDATES),
+
+ /**
+ * Specifies that the function reads only INSERT and UPDATE_AFTER rows of
this table argument
+ * and skips UPDATE_BEFORE and DELETE rows, which may therefore be
incomplete or missing.
+ *
+ * <p>The planner then needs no ChangelogNormalize in front of the
function, for example when
+ * the input has no upsert key, filters on non-key columns, or reads
metadata columns. Reserved
+ * for built-in functions.
+ */
+ SKIP_RETRACTIONS(SUPPORT_UPDATES);
Review Comment:
Done.
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/optimize/program/FlinkChangelogModeInferenceProgram.scala:
##########
@@ -1352,11 +1352,21 @@ class FlinkChangelogModeInferenceProgram extends
FlinkOptimizeProgram[StreamOpti
* the node who should satisfy the requiredTrait
* @param requiredTrait
* the required DeleteKindTrait
+ * @param retractionsSkipped
+ * true if a consumer above skips retractions (see
[[StaticArgumentTrait.SKIP_RETRACTIONS]])
+ * and is reached only through nodes that forward rows one by one (Calc,
Exchange, Union,
+ * ...). Every other node resets it, because it reads the deletes
itself. If true, deletes may
+ * be incomplete:
+ * - a Calc may drop the key of a key-only delete,
Review Comment:
Done.
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/optimize/program/FlinkChangelogModeInferenceProgram.scala:
##########
@@ -1352,11 +1352,21 @@ class FlinkChangelogModeInferenceProgram extends
FlinkOptimizeProgram[StreamOpti
* the node who should satisfy the requiredTrait
* @param requiredTrait
* the required DeleteKindTrait
+ * @param retractionsSkipped
+ * true if a consumer above skips retractions (see
[[StaticArgumentTrait.SKIP_RETRACTIONS]])
+ * and is reached only through nodes that forward rows one by one (Calc,
Exchange, Union,
+ * ...). Every other node resets it, because it reads the deletes
itself. If true, deletes may
+ * be incomplete:
Review Comment:
Done.
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/optimize/program/FlinkChangelogModeInferenceProgram.scala:
##########
@@ -1893,7 +1897,7 @@ class FlinkChangelogModeInferenceProgram extends
FlinkOptimizeProgram[StreamOpti
tableArg.is(StaticArgumentTrait.SUPPORT_UPDATES) &&
!getModifyKindSet(input).isInsertOnly
val isInsertOnlyOutput = getModifyKindSet(process).isInsertOnly
!isSetSemantic && !requiresRetractions && isUpdatingInput &&
isInsertOnlyOutput &&
- hasNonEmptyUpsertKey(input)
+ (tableArg.is(StaticArgumentTrait.SKIP_RETRACTIONS) ||
hasNonEmptyUpsertKey(input))
Review Comment:
Done.
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/ToAppendTestPrograms.java:
##########
@@ -66,6 +66,28 @@ public class ToAppendTestPrograms {
.runSql("INSERT INTO sink SELECT * FROM TO_APPEND(input =>
TABLE source_table)")
.build();
+ public static final TableTestProgram UNION_ALL =
+ TableTestProgram.of(
+ "to-append-union-all",
+ "upserts of both inputs become inserts and the
deletes are dropped")
+ .setupTableSource(UPSERT_SOURCE)
+ .setupTableSource(
+ SourceTestStep.newBuilder("other_source_table")
+ .addSchema("id INT PRIMARY KEY NOT
ENFORCED", "v STRING")
+ .addMode(ChangelogMode.upsert(true))
Review Comment:
Done, `UNION_ALL` now mixes a key-only-delete and a full-delete source.
--
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]