twalthr commented on a change in pull request #13732:
URL: https://github.com/apache/flink/pull/13732#discussion_r510146400
##########
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:
I would suggest to keep it as it is. Users can use backticks and leader
epoch is not very frequently used. Furthermore, once we introduce metadata for
formats such as `debezium-json.ingestion-timestamp` it would be confusing if
the format identifier changes from `debezium-json` to `debezium_json` for
metadata.
----------------------------------------------------------------
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]