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

 ##########
 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:
   For now I've added a log warning. Is adding logging for both [key missing 
and value present and value missing key present] a good idea, or do u see this 
to be a expected usage in which case I can even remove the existing logging

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