sijie commented on a change in pull request #2537: [schema] enable Schema.AUTO 
if functions or connectors are using GenericRecord
URL: https://github.com/apache/incubator-pulsar/pull/2537#discussion_r215859148
 
 

 ##########
 File path: 
pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/source/TopicSchema.java
 ##########
 @@ -68,24 +69,31 @@ public TopicSchema(PulsarClient client) {
     }
 
     public Schema<?> getSchema(String topic, Class<?> clazz, SchemaType 
schemaType) {
-        return cachedSchemas.computeIfAbsent(topic, t -> extractSchema(clazz, 
schemaType));
+        return cachedSchemas.computeIfAbsent(topic, t -> 
newSchemaInstance(clazz, schemaType));
     }
 
     /**
      * If the topic is already created, we should be able to fetch the schema 
type (avro, json, ...)
      */
     private SchemaType getSchemaTypeOrDefault(String topic, Class<?> clazz) {
-        Optional<SchemaInfo> schema = ((PulsarClientImpl) 
client).getSchema(topic).join();
-        if (schema.isPresent()) {
-            return schema.get().getType();
+        if (GenericRecord.class.isAssignableFrom(clazz)) {
+            return SchemaType.AUTO;
         } else {
-            return getDefaultSchemaType(clazz);
+            Optional<SchemaInfo> schema = ((PulsarClientImpl) 
client).getSchema(topic).join();
 
 Review comment:
   SchemaType.AUTO is to generate `GenericRecord`. we still need to get schema 
info for other type args.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to