You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/07/11 07:06:23 UTC

[GitHub] [pulsar] congbobo184 commented on a change in pull request #4692: [pulsar-sql]Pulsar SQL supports pulsar's primitive schemas and schema verison

congbobo184 commented on a change in pull request #4692: [pulsar-sql]Pulsar SQL supports pulsar's primitive schemas and schema verison
URL: https://github.com/apache/pulsar/pull/4692#discussion_r302391508
 
 

 ##########
 File path: pulsar-sql/presto-pulsar/src/main/java/org/apache/pulsar/sql/presto/JSONSchemaHandler.java
 ##########
 @@ -64,31 +73,23 @@ public Object deserialize(ByteBuf payload) {
         }
 
         payload.readBytes(buffer, 0, size);
-
-        try {
-            return dslJson.deserialize(Map.class, buffer, size);
-        } catch (IOException e) {
-            log.error("Failed to deserialize Json object", e);
-            return null;
-        }
+        return genericJsonSchema.decode(buffer);
     }
 
     @Override
     public Object extractField(int index, Object currentRecord) {
         try {
-            Map jsonObject = (Map) currentRecord;
+            GenericJsonRecord genericJsonRecord = (GenericJsonRecord) currentRecord;
             PulsarColumnHandle pulsarColumnHandle = columnHandles.get(index);
-
-            String[] fieldNames = pulsarColumnHandle.getFieldNames();
-            Object field = jsonObject.get(fieldNames[0]);
-            if (field == null) {
-                return null;
-            }
-            for (int i = 1; i < fieldNames.length ; i++) {
-                field = ((Map) field).get(fieldNames[i]);
-                if (field == null) {
-                    return null;
+            String[] names = pulsarColumnHandle.getName().split("\\.");
 
 Review comment:
   I will change this. Thank you for giving me this advice.

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