AHeise commented on code in PR #258:
URL:
https://github.com/apache/flink-connector-kafka/pull/258#discussion_r3323329665
##########
flink-connector-kafka/src/main/java/org/apache/flink/streaming/connectors/kafka/table/KafkaDynamicSink.java:
##########
@@ -457,6 +465,47 @@ public Object read(RowData row, int pos) {
}
}),
+ /**
+ * Wire-faithful alternative to {@code headers}: preserves duplicate
keys and insertion
+ * order using {@code ARRAY<ROW<key STRING, value BYTES>>} instead of
a lossy MAP.
+ */
+ MULTI_HEADERS(
+ "multi-headers",
+ DataTypes.ARRAY(
+ DataTypes.ROW(
+ DataTypes.FIELD(
+ "key",
DataTypes.STRING().nullable()),
+ DataTypes.FIELD(
+ "value",
DataTypes.BYTES().nullable()))
+ .notNull())
+ .nullable(),
+ new MetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object read(RowData row, int pos) {
+ if (row.isNullAt(pos)) {
+ return null;
+ }
+ final ArrayData arrayData = row.getArray(pos);
+ final List<Header> headers = new ArrayList<>();
+ for (int i = 0; i < arrayData.size(); i++) {
+ if (!arrayData.isNullAt(i)) {
+ final RowData headerRow = arrayData.getRow(i,
2);
+ if (headerRow.isNullAt(0)) {
+ throw new IllegalArgumentException(
Review Comment:
Yes, good catch. I'll use the same behavior as regular header to skip
instead. The main reason for nullable values is the ease of using it in queries.
--
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]