[ 
https://issues.apache.org/jira/browse/BEAM-10893?focusedWorklogId=505594&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-505594
 ]

ASF GitHub Bot logged work on BEAM-10893:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 28/Oct/20 07:15
            Start Date: 28/Oct/20 07:15
    Worklog Time Spent: 10m 
      Work Description: piotr-szuberski commented on a change in pull request 
#12839:
URL: https://github.com/apache/beam/pull/12839#discussion_r513222917



##########
File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/kafka/BeamKafkaJsonTable.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.extensions.sql.meta.provider.kafka;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.List;
+import org.apache.beam.sdk.schemas.Schema;
+import org.apache.beam.sdk.transforms.DoFn;
+import org.apache.beam.sdk.transforms.PTransform;
+import org.apache.beam.sdk.transforms.ParDo;
+import org.apache.beam.sdk.util.RowJson;
+import org.apache.beam.sdk.util.RowJsonUtils;
+import org.apache.beam.sdk.values.KV;
+import org.apache.beam.sdk.values.PCollection;
+import org.apache.beam.sdk.values.Row;
+
+public class BeamKafkaJsonTable extends BeamKafkaTable {
+  public BeamKafkaJsonTable(Schema beamSchema, String bootstrapServers, 
List<String> topics) {
+    super(beamSchema, bootstrapServers, topics);
+  }
+
+  @Override
+  public PTransform<PCollection<KV<byte[], byte[]>>, PCollection<Row>> 
getPTransformForInput() {
+    ObjectMapper objectMapper =
+        
RowJsonUtils.newObjectMapperWith(RowJson.RowJsonDeserializer.forSchema(schema));
+    return new BeamKafkaJsonTable.JsonRecorderDecoder(schema, objectMapper);
+  }
+
+  @Override
+  public PTransform<PCollection<Row>, PCollection<KV<byte[], byte[]>>> 
getPTransformForOutput() {
+    ObjectMapper objectMapper =
+        
RowJsonUtils.newObjectMapperWith(RowJson.RowJsonSerializer.forSchema(schema));
+    return new BeamKafkaJsonTable.JsonRecorderEncoder(objectMapper);
+  }
+
+  /** A PTransform to convert {@code KV<byte[], byte[]>} to {@link Row}. */
+  public static class JsonRecorderDecoder

Review comment:
       Done




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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 505594)
    Time Spent: 2h 20m  (was: 2h 10m)

> Add JSON suport to Kafka Table Provider
> ---------------------------------------
>
>                 Key: BEAM-10893
>                 URL: https://issues.apache.org/jira/browse/BEAM-10893
>             Project: Beam
>          Issue Type: New Feature
>          Components: dsl-sql, io-java-kafka
>            Reporter: Piotr Szuberski
>            Assignee: Piotr Szuberski
>            Priority: P2
>          Time Spent: 2h 20m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to