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 2018/09/06 18:10:00 UTC

[GitHub] jerrypeng commented on a change in pull request #2515: support nested fields in Pulsar presto connector

jerrypeng commented on a change in pull request #2515: support nested fields in Pulsar presto connector
URL: https://github.com/apache/incubator-pulsar/pull/2515#discussion_r215725500
 
 

 ##########
 File path: pulsar-sql/presto-pulsar/src/main/java/org/apache/pulsar/sql/presto/AvroSchemaHandler.java
 ##########
 @@ -55,9 +55,23 @@ public Object deserialize(byte[] bytes) {
     public Object extractField(int index, Object currentRecord) {
         try {
             GenericRecord record = (GenericRecord) currentRecord;
-            return record.get(this.columnHandles.get(index).getPositionIndex());
+            PulsarColumnHandle pulsarColumnHandle = this.columnHandles.get(index);
+            Integer[] positionIndices = pulsarColumnHandle.getPositionIndices();
+            Object curr = record.get(positionIndices[0]);
+            if (curr == null) {
+                return null;
+            }
+            if (positionIndices.length > 0) {
+                for (int i = 1 ; i < positionIndices.length; i++) {
+                    curr = ((GenericRecord) curr).get(positionIndices[i]);
+                    if (curr == null) {
+                        return null;
+                    }
+                }
+            }
+            return curr;
         } catch (Exception ex) {
-            log.error(ex);
+            log.debug(ex,"%s", ex);
 
 Review comment:
   Just to keep things consistent with the presto project, so when we want to move the connector to the presto repo we can do it with little code modification

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


With regards,
Apache Git Services