AHeise commented on a change in pull request #16142:
URL: https://github.com/apache/flink/pull/16142#discussion_r660018383



##########
File path: 
flink-connectors/flink-connector-kafka/src/main/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaProducer.java
##########
@@ -860,7 +861,7 @@ public void invoke(
             String targetTopic = keyedSchema.getTargetTopic(next);
             if (targetTopic == null) {
                 targetTopic = defaultTopicId;
-            } else if (defaultTopicId == null) {
+            } else if (TOPIC_UNSPECIFIED.equals(defaultTopicId)) {

Review comment:
       Revert.

##########
File path: 
flink-connectors/flink-connector-kafka/src/main/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaProducer.java
##########
@@ -900,7 +901,7 @@ public void invoke(
                 String targetTopic = contextAwareSchema.getTargetTopic(next);
                 if (targetTopic == null) {
                     targetTopic = defaultTopicId;
-                } else if (defaultTopicId == null) {
+                } else if (TOPIC_UNSPECIFIED.equals(defaultTopicId)) {

Review comment:
       Revert.

##########
File path: 
flink-connectors/flink-connector-kafka/src/main/java/org/apache/flink/streaming/connectors/kafka/table/DynamicKafkaSerializationSchema.java
##########
@@ -166,7 +168,7 @@ public void setPartitions(int[] partitions) {
 
     @Override
     public String getTargetTopic(RowData element) {
-        return topic == null
+        return TOPIC_UNSPECIFIED.equals(topic)
                 ? readMetadata(element, 
KafkaDynamicSink.WritableMetadata.TOPIC)

Review comment:
       I just saw that `readMetadata` can return `null` which it shouldn't (and 
it's not annotated!). 
   What is the expected target topic then? I guess `TOPIC[0]`?
   But what happens if the user didn't set `TOPIC`? Can you check the schema if 
the column is nullable and fail if `TOPIC` is empty/unset?




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