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_r215725765
##########
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:
Also I didn't want to introduce more dependencies than necessary and the
logger already comes with airlift bootstrap that we need to depend on anyways
----------------------------------------------------------------
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