Savonitar commented on code in PR #258:
URL:
https://github.com/apache/flink-connector-kafka/pull/258#discussion_r3319204673
##########
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:
Could u please clarify nullability on the key field?
Schema declares
```
DataTypes.ARRAY(
DataTypes.ROW(
DataTypes.FIELD(
"key",
DataTypes.STRING().nullable()),
DataTypes.FIELD(
"value",
DataTypes.BYTES().nullable()))
.notNull())
.nullable(),
```
however, at this line
```
if (headerRow.isNullAt(0)) {
throw new IllegalArgumentException(
"Null header keys are not permitted.");
```
we throw.
So we throw for a value the schema told the planner is valid. Shouldn't
nullable() be notNull(), so the planner rejects null-key expressions at compile
time instead of the job crashing at runtime?
--
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]