gustavodemorais commented on code in PR #351:
URL:
https://github.com/apache/flink-connector-kafka/pull/351#discussion_r4615956448
##########
flink-connector-kafka/src/main/java/org/apache/flink/streaming/connectors/kafka/table/UpsertKafkaDynamicTableFactory.java:
##########
@@ -254,6 +259,35 @@ public DynamicTableSink createDynamicTableSink(Context
context) {
tableOptions.get(TRANSACTION_NAMING_STRATEGY));
}
+ private static boolean supportsKeyOnlyDeletes(
+ ReadableConfig tableOptions, ResolvedSchema schema) {
+ return writesToSingleTopic(tableOptions) &&
hasOnlyNullableValueColumns(schema);
+ }
+
+ /**
+ * A tombstone only needs the key, as long as the sink knows the target
topic. With a topic list
+ * or pattern, each row picks its topic from the {@code topic} metadata
column, which a key-only
+ * delete does not guarantee to carry. This makes sinks writing to
multiple topics incompatible
+ * with key-only deletes.
+ */
+ private static boolean writesToSingleTopic(ReadableConfig tableOptions) {
+ final List<String> topics = getTopics(tableOptions);
+ return topics != null && topics.size() == 1;
+ }
+
+ /**
+ * Key-only deletes leave the value columns NULL, which the NOT NULL
enforcer of Flink versions
+ * without FLINK-40477 rejects. Remove once the minimum Flink version
supported by the connector
Review Comment:
We have two checks: writesToSingleTopic and hasOnlyNullableValueColumns.
- **writesToSingleTopic** stays. With a single topic, the sink knows the
target topic without looking at the row. With a topic list or pattern, each row
picks its topic from the topic column, and a key-only delete doesn't guarantee
to carry it.
- **hasOnlyNullableValueColumns** can go once the connector's minimum Flink
version is 2.4. Before 2.4, the NOT NULL constraint enforcer fails the job on a
key-only delete into NOT NULL value columns. Since 2.4 (FLINK-40477), the
enforcer skips the non-key columns of key-only deletes.
--
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]