rdblue commented on a change in pull request #207: Add external schema mappings 
for files written with name-based schemas #40
URL: https://github.com/apache/incubator-iceberg/pull/207#discussion_r330283342
 
 

 ##########
 File path: core/src/main/java/org/apache/iceberg/avro/PruneColumns.java
 ##########
 @@ -100,36 +106,46 @@ public Schema union(Schema union, List<Schema> options) {
   }
 
   @Override
+  @SuppressWarnings("checkstyle:CyclomaticComplexity")
   public Schema array(Schema array, Schema element) {
-    if (array.getLogicalType() instanceof LogicalMap) {
+    if (array.getLogicalType() instanceof LogicalMap || 
AvroSchemaUtil.isKeyValueSchema(array.getElementType())) {
       Schema keyValue = array.getElementType();
-      int keyId = AvroSchemaUtil.getFieldId(keyValue.getField("key"));
-      int valueId = AvroSchemaUtil.getFieldId(keyValue.getField("value"));
+      Integer keyId = fieldId(keyValue.getField("key"));
+      Integer valueId = fieldId(keyValue.getField("value"));
+      if (keyId == null) {
+        Preconditions.checkState(valueId == null, "Map schema %s has value id 
but not key id", array);
 
 Review comment:
   This could happen if the mapping has key, but not value. I'm not sure that 
it's a good idea to throw an exception in this case. Maybe just warn and not 
project?

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to