[
https://issues.apache.org/jira/browse/BEAM-12008?focusedWorklogId=621155&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-621155
]
ASF GitHub Bot logged work on BEAM-12008:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 09/Jul/21 19:41
Start Date: 09/Jul/21 19:41
Worklog Time Spent: 10m
Work Description: chamikaramj commented on a change in pull request
#15090:
URL: https://github.com/apache/beam/pull/15090#discussion_r667173929
##########
File path:
sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/NullableKeyKafkaRecordCoder.java
##########
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.kafka;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.apache.beam.sdk.coders.BooleanCoder;
+import org.apache.beam.sdk.coders.ByteArrayCoder;
+import org.apache.beam.sdk.coders.Coder;
+import org.apache.beam.sdk.coders.IterableCoder;
+import org.apache.beam.sdk.coders.KvCoder;
+import org.apache.beam.sdk.coders.StringUtf8Coder;
+import org.apache.beam.sdk.coders.StructuredCoder;
+import org.apache.beam.sdk.coders.VarIntCoder;
+import org.apache.beam.sdk.coders.VarLongCoder;
+import org.apache.beam.sdk.values.KV;
+import org.apache.kafka.clients.consumer.ConsumerRecord;
+import org.apache.kafka.common.header.Header;
+import org.apache.kafka.common.header.Headers;
+
+/** {@link Coder} for {@link KafkaRecord}. */
+@SuppressWarnings({
+ "rawtypes", // TODO(https://issues.apache.org/jira/browse/BEAM-10556)
+ "nullness" // TODO(https://issues.apache.org/jira/browse/BEAM-10402)
+})
+public class NullableKeyKafkaRecordCoder<K, V> extends
StructuredCoder<KafkaRecord<K, V>> {
Review comment:
Ah right. Yeah let's remove NullableKeyKafkaRecordCoder and the test :)
--
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 621155)
Time Spent: 7h 20m (was: 7h 10m)
> KafkaIO does not handle null keys
> ---------------------------------
>
> Key: BEAM-12008
> URL: https://issues.apache.org/jira/browse/BEAM-12008
> Project: Beam
> Issue Type: Bug
> Components: io-java-kafka
> Reporter: Daniel Collins
> Assignee: Weiwen Xu
> Priority: P2
> Labels: stale-P2
> Time Spent: 7h 20m
> Remaining Estimate: 0h
>
> Kafka
> [ConsumerRecord|https://kafka.apache.org/27/javadoc/org/apache/kafka/clients/consumer/ConsumerRecord.html#key--]
> and
> [ProducerRecord|https://kafka.apache.org/27/javadoc/org/apache/kafka/clients/producer/ProducerRecord.html#key--]
> 'key' fields are explicitly allowed to be null. In addition, on the producer
> side, setting a null key is the way that the user indicates that they want a
> [random partition for their
> message|[https://github.com/apache/kafka/blob/9adfac280392da0837cfd8d582bc540951e94087/clients/src/main/java/org/apache/kafka/clients/producer/internals/DefaultPartitioner.java#L67].]
>
> Beam KafkaIO does not support null keys in byte[] mode (read side:
> [https://github.com/apache/beam/blob/9e0997760cf3320f1a1d0c4342d3dff559a25775/sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaIO.java#L727|https://github.com/apache/beam/blob/9e0997760cf3320f1a1d0c4342d3dff559a25775/sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaIO.java#L727)]
> write side:
> [https://github.com/apache/beam/blob/9e0997760cf3320f1a1d0c4342d3dff559a25775/sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaRecordCoder.java#L58])
>
> since it would defer to ByteArrayCoder which does not support null arrays.
>
> BeamKafkaTable suffers the same issue
> https://github.com/apache/beam/blob/9e0997760cf3320f1a1d0c4342d3dff559a25775/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/kafka/BeamKafkaTable.java#L144
--
This message was sent by Atlassian Jira
(v8.3.4#803005)