hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shiv...@apache.org
Subject [1/2] incubator-hawq git commit: HAWQ-53. Fix to handling nulls in complex data types in avro via pxf
Date Thu, 22 Oct 2015 22:32:37 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master d89788de7 -> b10897824


HAWQ-53. Fix to handling nulls in complex data types in avro via pxf


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/098e241d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/098e241d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/098e241d

Branch: refs/heads/master
Commit: 098e241db115d8cd9fa3f710f546fb300afe9db0
Parents: 7ad8950
Author: Shivram Mani <shivram.mani@gmail.com>
Authored: Wed Oct 21 15:44:21 2015 -0700
Committer: Shivram Mani <shivram.mani@gmail.com>
Committed: Wed Oct 21 15:44:21 2015 -0700

----------------------------------------------------------------------
 .../pivotal/pxf/plugins/hdfs/AvroResolver.java   | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/098e241d/pxf/pxf-hdfs/src/main/java/com/pivotal/pxf/plugins/hdfs/AvroResolver.java
----------------------------------------------------------------------
diff --git a/pxf/pxf-hdfs/src/main/java/com/pivotal/pxf/plugins/hdfs/AvroResolver.java b/pxf/pxf-hdfs/src/main/java/com/pivotal/pxf/plugins/hdfs/AvroResolver.java
index 8b86479..5249877 100644
--- a/pxf/pxf-hdfs/src/main/java/com/pivotal/pxf/plugins/hdfs/AvroResolver.java
+++ b/pxf/pxf-hdfs/src/main/java/com/pivotal/pxf/plugins/hdfs/AvroResolver.java
@@ -161,22 +161,31 @@ public class AvroResolver extends Plugin implements ReadResolver {
 
         Schema.Type fieldType = fieldSchema.getType();
         int ret = 0;
-        Object value;
+        Object value = fieldValue;
 
         switch (fieldType) {
             case ARRAY:
+                if(fieldValue == null) {
+                    return addOneFieldToRecord(record, TEXT, fieldValue);
+                }
                 List<OneField> listRecord = new LinkedList<>();
                 ret = setArrayField(listRecord, fieldValue, fieldSchema);
                 addOneFieldToRecord(record, TEXT, String.format("[%s]",
                         HdfsUtilities.toString(listRecord, collectionDelim)));
                 break;
             case MAP:
+                if(fieldValue == null) {
+                    return addOneFieldToRecord(record, TEXT, fieldValue);
+                }
                 List<OneField> mapRecord = new LinkedList<>();
                 ret = setMapField(mapRecord, fieldValue, fieldSchema);
                 addOneFieldToRecord(record, TEXT, String.format("{%s}",
                         HdfsUtilities.toString(mapRecord, collectionDelim)));
                 break;
             case RECORD:
+                if(fieldValue == null) {
+                    return addOneFieldToRecord(record, TEXT, fieldValue);
+                }
                 List<OneField> recRecord = new LinkedList<>();
                 ret = setRecordField(recRecord, fieldValue, fieldSchema);
                 addOneFieldToRecord(record, TEXT, String.format("{%s}",
@@ -201,15 +210,12 @@ public class AvroResolver extends Plugin implements ReadResolver {
                         fieldSchema.getTypes().get(unionIndex));
                 break;
             case ENUM:
-                value = (fieldValue != null) ? fieldValue : null;
                 ret = addOneFieldToRecord(record, TEXT, value);
                 break;
             case INT:
-                value = (fieldValue != null) ? fieldValue : null;
                 ret = addOneFieldToRecord(record, INTEGER, value);
                 break;
             case DOUBLE:
-                value = (fieldValue != null) ? fieldValue : null;
                 ret = addOneFieldToRecord(record, FLOAT8, value);
                 break;
             case STRING:
@@ -218,23 +224,18 @@ public class AvroResolver extends Plugin implements ReadResolver {
                 ret = addOneFieldToRecord(record, TEXT, value);
                 break;
             case FLOAT:
-                value = (fieldValue != null) ? fieldValue : null;
                 ret = addOneFieldToRecord(record, REAL, value);
                 break;
             case LONG:
-                value = (fieldValue != null) ? fieldValue : null;
                 ret = addOneFieldToRecord(record, BIGINT, value);
                 break;
             case BYTES:
-                value = (fieldValue != null) ? fieldValue : null;
                 ret = addOneFieldToRecord(record, BYTEA, value);
                 break;
             case BOOLEAN:
-                value = (fieldValue != null) ? fieldValue : null;
                 ret = addOneFieldToRecord(record, BOOLEAN, value);
                 break;
             case FIXED:
-                value = (fieldValue != null) ? fieldValue : null;
                 ret = addOneFieldToRecord(record, BYTEA, value);
                 break;
             default:


Mime
View raw message