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



##########
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:
       True, then I need to change also the recommendations in 
`SupportsMetadata` interfaces:
   ```
         * <p>Metadata key names follow the same pattern as mentioned in {@link 
Factory}. In case of duplicate
         * names in format and source keys, format keys shall have higher 
precedence.
   ```




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