pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [pulsar] srkukarni commented on a change in pull request #4028: Functions should make use of Schema Types that are available
Date Sat, 13 Apr 2019 04:03:03 GMT
srkukarni 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_r275103780
 
 

 ##########
 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:
   Will do the other changes, but wanted to discuss this.
   IMO the current behaviour of functions wrt these is buggy. When I output Date for instance
in my function, I expect it to go out as Date and not as bytes as it does right now. This
means that all downstream processes(whether functions/sql, etc) will have no other way to
interpret this data other than bytes. This basically renders functions useless for a lot of
use cases.

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


With regards,
Apache Git Services

Mime
View raw message