twalthr commented on a change in pull request #13732:
URL: https://github.com/apache/flink/pull/13732#discussion_r510377821



##########
File path: 
flink-connectors/flink-connector-kafka/src/main/java/org/apache/flink/streaming/connectors/kafka/table/KafkaDynamicSource.java
##########
@@ -202,4 +268,169 @@ public int hashCode() {
 
                return kafkaConsumer;
        }
+
+       // 
--------------------------------------------------------------------------------------------
+       // Metadata handling
+       // 
--------------------------------------------------------------------------------------------
+
+       private enum ReadableMetadata {
+               TOPIC(
+                       "topic",
+                       DataTypes.STRING().notNull(),
+                       record -> StringData.fromString(record.topic())
+               ),
+
+               PARTITION(
+                       "partition",
+                       DataTypes.INT().notNull(),
+                       ConsumerRecord::partition
+               ),
+
+               HEADERS(
+                       "headers",
+                       // key and value of the map are nullable to make 
handling easier in queries
+                       DataTypes.MAP(DataTypes.STRING().nullable(), 
DataTypes.BYTES().nullable()).notNull(),
+                       record -> {
+                               final Map<StringData, byte[]> map = new 
HashMap<>();
+                               for (Header header : record.headers()) {
+                                       
map.put(StringData.fromString(header.key()), header.value());
+                               }
+                               return new GenericMapData(map);
+                       }
+               ),
+
+               LEADER_EPOCH(
+                       "leader-epoch",

Review comment:
       Yes, we can shorten them. The idea was to design the metadata similar to 
regular options. So if key and value are defined they would get a `key.` and 
`value.` prefix. That should be enough. We don't need the `debezium-json`.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to