AHeise commented on a change in pull request #16142:
URL: https://github.com/apache/flink/pull/16142#discussion_r659735774
##########
File path:
flink-connectors/flink-connector-kafka/src/main/java/org/apache/flink/streaming/connectors/kafka/table/KafkaDynamicTableFactory.java
##########
@@ -224,7 +224,7 @@ public DynamicTableSink createDynamicTableSink(Context
context) {
keyProjection,
valueProjection,
keyPrefix,
- tableOptions.get(TOPIC).get(0),
+ tableOptions.getOptional(TOPIC).isPresent() ?
tableOptions.get(TOPIC).get(0) : null,
Review comment:
Here at this place, you could use `unspecified!` instead of null. Then
you don't need to change anything in the `KafkaProducer`. If you use a special
character like `!`, this will fail hard if the user row does not specify the
column.
##########
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]