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



##########
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:
       But even for `key.` and `value.`, users would need to backticks or the 
FROM clause. I would stick to the naming convention to not cause confusion.




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