You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2021/01/05 15:07:18 UTC

[GitHub] [hudi] yanghua commented on a change in pull request #2405: [HUDI-1506] Fix wrong exception thrown in HoodieAvroUtils

yanghua commented on a change in pull request #2405:
URL: https://github.com/apache/hudi/pull/2405#discussion_r551988234



##########
File path: hudi-common/src/main/java/org/apache/hudi/avro/HoodieAvroUtils.java
##########
@@ -428,10 +429,14 @@ public static Object getNestedFieldVal(GenericRecord record, String fieldName, b
 
     if (returnNullIfNotFound) {
       return null;
-    } else {
+    }
+
+    if (recordSchema.getField(parts[i]) == null) {

Review comment:
       Can it be `else if`?

##########
File path: hudi-common/src/main/java/org/apache/hudi/avro/HoodieAvroUtils.java
##########
@@ -428,10 +429,14 @@ public static Object getNestedFieldVal(GenericRecord record, String fieldName, b
 
     if (returnNullIfNotFound) {
       return null;
-    } else {
+    }
+
+    if (recordSchema.getField(parts[i]) == null) {
       throw new HoodieException(
           fieldName + "(Part -" + parts[i] + ") field not found in record. Acceptable fields were :"
               + valueNode.getSchema().getFields().stream().map(Field::name).collect(Collectors.toList()));

Review comment:
       Can we reuse `recordSchema ` here?




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