pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [pulsar] sijie commented on a change in pull request #4028: Functions should make use of Schema Types that are available
Date Sat, 13 Apr 2019 06:07:11 GMT
sijie commented on a change in pull request #4028: Functions should make use of Schema Types
that are available 
URL: https://github.com/apache/pulsar/pull/4028#discussion_r275106412

 File path: pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/source/TopicSchema.java
 @@ -104,20 +101,41 @@ private SchemaType getSchemaTypeOrDefault(String topic, Class<?>
clazz) {
     private static SchemaType getDefaultSchemaType(Class<?> clazz) {
-        if (byte[].class.equals(clazz)
-            || ByteBuf.class.equals(clazz)
-            || ByteBuffer.class.equals(clazz)) {
-            return SchemaType.NONE;
+        if (byte[].class.equals(clazz)) {
+            return BytesSchema.of().getSchemaInfo().getType();
+        } else if (ByteBuf.class.equals(clazz)) {
+            return ByteBufSchema.of().getSchemaInfo().getType();
+        } else if (ByteBuffer.class.equals(clazz)) {
+            return ByteBufferSchema.of().getSchemaInfo().getType();
+        } else if (Byte.class.equals(clazz)) {
+            return ByteSchema.of().getSchemaInfo().getType();
         } else if (GenericRecord.class.isAssignableFrom(clazz)) {
             // the function is taking generic record, so we do auto schema detection
             return SchemaType.AUTO_CONSUME;
         } else if (String.class.equals(clazz)) {
-            // If type is String, then we use schema type string, otherwise we fallback on
default schema
             return SchemaType.STRING;
         } else if (isProtobufClass(clazz)) {
             return SchemaType.PROTOBUF;
         } else if (KeyValue.class.equals(clazz)) {
             return SchemaType.KEY_VALUE;
+        } else if (Date.class.equals(clazz)) {
 Review comment:
   1) the default is JSON.
   2) I agree it is buggy. But there were functions running before. You can’t break them.
We have been adding quite a few changes that break users. I would prefer we have a solution
for BC. Otherwise it looks really bad. Especially this change is about changing schema. I
would prefer making them compatible.
   3) if people want to use Date, he can specify schema type or precreate a topic with Date
schema. Correct?

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:

With regards,
Apache Git Services

View raw message