dpcollins-google commented on a change in pull request #13825:
URL: https://github.com/apache/beam/pull/13825#discussion_r567051699



##########
File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/kafka/KafkaTableProvider.java
##########
@@ -69,65 +58,16 @@ public BeamSqlTable buildBeamSqlTable(Table table) {
       topics.add(topic.toString());
     }
 
-    PayloadFormat payloadFormat =
-        properties.containsKey("format")
-            ? 
PayloadFormat.valueOf(properties.getString("format").toUpperCase())
-            : PayloadFormat.CSV;
-
-    switch (payloadFormat) {
-      case CSV:
-        return new BeamKafkaCSVTable(schema, bootstrapServers, topics);
-      case AVRO:
-        return new BeamKafkaAvroTable(schema, bootstrapServers, topics);
-      case JSON:
-        return new BeamKafkaJsonTable(schema, bootstrapServers, topics);
-      case PROTO:
-        return protoTable(schema, bootstrapServers, topics, properties);
-      case THRIFT:
-        return thriftTable(schema, bootstrapServers, topics, properties);
-      default:
-        throw new IllegalArgumentException("Unsupported payload format: " + 
payloadFormat);
-    }
-  }
-
-  private BeamKafkaProtoTable protoTable(
-      Schema schema, String bootstrapServers, List<String> topics, JSONObject 
properties) {
-    String protoClassName = properties.getString("protoClass");
-    try {
-      Class<?> protoClass = Class.forName(protoClassName);
-      return new BeamKafkaProtoTable(schema, bootstrapServers, topics, 
protoClass);
-    } catch (ClassNotFoundException e) {
-      throw new IllegalArgumentException("Incorrect proto class provided: " + 
protoClassName);
-    }
-  }
-
-  private BeamKafkaThriftTable thriftTable(
-      Schema schema, String bootstrapServers, List<String> topics, JSONObject 
properties) {
-    final String thriftClassName = properties.getString("thriftClass");
-    final String thriftProtocolFactoryClassName =
-        properties.getString("thriftProtocolFactoryClass");
-    try {
-      final Class<TBase> thriftClass = (Class<TBase>) 
Class.forName(thriftClassName);
-      final TProtocolFactory thriftProtocolFactory;
-      try {
-        final Class<TProtocolFactory> thriftProtocolFactoryClass =
-            (Class<TProtocolFactory>) 
Class.forName(thriftProtocolFactoryClassName);
-        thriftProtocolFactory = 
thriftProtocolFactoryClass.getDeclaredConstructor().newInstance();
-      } catch (ClassNotFoundException e) {
-        throw new IllegalArgumentException(
-            "Incorrect thrift protocol factory class provided: " + 
thriftProtocolFactoryClassName);
-      } catch (InstantiationException
-          | IllegalAccessException
-          | InvocationTargetException
-          | NoSuchMethodException e) {
-        throw new IllegalStateException(
-            "Could not instantiate the thrift protocol factory class", e);
-      }
-      return new BeamKafkaThriftTable<>(
-          schema, bootstrapServers, topics, thriftClass, 
thriftProtocolFactory);
-    } catch (ClassNotFoundException e) {
-      throw new IllegalArgumentException("Incorrect thrift class provided: " + 
thriftClassName);
+    String payloadFormat =
+        properties.containsKey("format") ? properties.getString("format") : 
"csv";
+    if (payloadFormat.equals("csv")) {

Review comment:
       Done.

##########
File path: 
sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/io/payloads/AvroPayloadSerializerProvider.java
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.schemas.io.payloads;
+
+import com.google.auto.service.AutoService;
+import java.util.Map;
+import org.apache.beam.sdk.annotations.Experimental;
+import org.apache.beam.sdk.annotations.Experimental.Kind;
+import org.apache.beam.sdk.annotations.Internal;
+import org.apache.beam.sdk.schemas.Schema;
+import org.apache.beam.sdk.schemas.utils.AvroUtils;
+
+@Internal
+@Experimental(Kind.SCHEMAS)
+@AutoService(PayloadSerializerProvider.class)
+public class AvroPayloadSerializerProvider implements 
PayloadSerializerProvider {
+  @Override
+  public String identifier() {
+    return "avro";
+  }
+
+  @Override
+  public PayloadSerializer getSerializer(Schema schema, Map<String, Object> 
tableParams) {

Review comment:
       Its a place for Proto/Thrift parameters. Added a comment.

##########
File path: gradle/wrapper/gradle-wrapper.properties
##########
@@ -1,5 +1,5 @@
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-all.zip
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
-zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME

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]


Reply via email to