nsivabalan commented on a change in pull request #2619:
URL: https://github.com/apache/hudi/pull/2619#discussion_r597317661



##########
File path: 
hudi-utilities/src/main/java/org/apache/hudi/utilities/deser/KafkaAvroSchemaDeserializer.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.hudi.utilities.deser;
+
+import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient;
+import io.confluent.kafka.serializers.KafkaAvroDeserializer;
+import org.apache.avro.Schema;
+
+import org.apache.hudi.DataSourceWriteOptions;
+import org.apache.hudi.common.config.TypedProperties;
+import org.apache.hudi.common.util.ReflectionUtils;
+import org.apache.hudi.exception.HoodieException;
+import org.apache.hudi.utilities.schema.SchemaProvider;
+import org.apache.kafka.common.errors.SerializationException;
+import org.apache.spark.api.java.JavaSparkContext;
+
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
+
+/**
+ * Extending {@link KafkaAvroSchemaDeserializer} as we need to be able to 
inject reader schema during deserialization.
+ */
+public class KafkaAvroSchemaDeserializer extends KafkaAvroDeserializer {
+
+  private Schema sourceSchema;
+
+  public KafkaAvroSchemaDeserializer() {}
+
+  public KafkaAvroSchemaDeserializer(SchemaRegistryClient client, Map<String, 
?> props) {
+    super(client, props);
+  }
+
+  @Override
+  public void configure(Map<String, ?> configs, boolean isKey) {
+    super.configure(configs, isKey);
+    try {
+      TypedProperties props = getConvertToTypedProperties(configs);
+      String className = 
props.getString(DataSourceWriteOptions.SCHEMA_PROVIDER_CLASS_PROP());
+      JavaSparkContext jsc = (JavaSparkContext) 
props.get(DataSourceWriteOptions.JAVA_SPARK_CONTEXT_PROP());

Review comment:
       @n3nash : we might have to discuss how to fetch jsc here. we can't pass 
null with reflection and so even though jsc may not be used by schemaProvider, 
we ought to send the jsc as last arg while instantiating the schema provider. 
Outside of this patch, also wanted to discuss why we have jsc as mandatory 
argument to base schemaProvider. may be some of the schemaProviders may not 
need it. 




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


Reply via email to