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

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

                Author: ASF GitHub Bot
            Created on: 20/Dec/20 17:10
            Start Date: 20/Dec/20 17:10
    Worklog Time Spent: 10m 
      Work Description: ccciudatu commented on a change in pull request #13572:
URL: https://github.com/apache/beam/pull/13572#discussion_r546403797



##########
File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/kafka/BeamKafkaThriftTable.java
##########
@@ -74,55 +92,81 @@ private static Schema thriftSchema(
 
   @Override
   protected PTransform<PCollection<KV<byte[], byte[]>>, PCollection<Row>> 
getPTransformForInput() {
-    final @NonNull SchemaProvider schemaProvider = ThriftSchema.provider();
-    return new PTransform<PCollection<KV<byte[], byte[]>>, PCollection<Row>>() 
{
-      @Override
-      @SuppressWarnings("nullness")
-      public PCollection<Row> expand(PCollection<KV<byte[], byte[]>> input) {
-        return input
-            .apply(Values.create())
-            
.apply(MapElements.into(typeDescriptor).via(BeamKafkaThriftTable.this::decode))
-            .setSchema(
-                schema,
-                typeDescriptor,
-                schemaProvider.toRowFunction(typeDescriptor),
-                schemaProvider.fromRowFunction(typeDescriptor))
-            .apply(Convert.toRows());
-      }
-    };
+    return new InputTransformer(typeDescriptor, coder, schema);
   }
 
-  private T decode(byte[] bytes) {
-    try {
-      return thriftCoder.decode(new ByteArrayInputStream(bytes));
-    } catch (IOException e) {
-      throw new IllegalStateException(e);
+  private static class InputTransformer<T extends TBase<?, ?>>

Review comment:
       I had a closer look and it seems like the proto `bytesToRow` and 
`rowToBytes` code has no real reason to be proto specific, as it can work with 
any `SchemaProvider` and `Coder` pair. I'll try to extract that into 
`org.apache.beam.sdk.util` and reuse it from both proto and thrift (and perhaps 
others, if I find more like this). This way I'll also add support for shuffled 
schemas in the thrift implementation for free.




----------------------------------------------------------------
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:
us...@infra.apache.org


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

    Worklog Id:     (was: 526544)
    Time Spent: 7h 10m  (was: 7h)

> Thrift support for KafkaTableProvider
> -------------------------------------
>
>                 Key: BEAM-11482
>                 URL: https://issues.apache.org/jira/browse/BEAM-11482
>             Project: Beam
>          Issue Type: New Feature
>          Components: dsl-sql, io-java-kafka
>            Reporter: Costi Ciudatu
>            Assignee: Costi Ciudatu
>            Priority: P2
>          Time Spent: 7h 10m
>  Remaining Estimate: 0h
>
> Kafka table provider can leverage the Thrift coder and schema provider 
> defined in the IO package to handle thrift input/output.



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

Reply via email to