You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/08/09 18:34:27 UTC
[GitHub] [iceberg] rdblue commented on a change in pull request #2943: Move Identifier field validation to Schema class
rdblue commented on a change in pull request #2943:
URL: https://github.com/apache/iceberg/pull/2943#discussion_r685429217
##########
File path: api/src/main/java/org/apache/iceberg/Schema.java
##########
@@ -93,11 +93,39 @@ public Schema(int schemaId, List<NestedField> columns, Map<String, Integer> alia
this.schemaId = schemaId;
this.struct = StructType.of(columns);
this.aliasToId = aliases != null ? ImmutableBiMap.copyOf(aliases) : null;
+
+ // validate IdentifierField
+ if (identifierFieldIds != null) {
+ Map<Integer, Integer> idToParent = TypeUtil.indexParents(this.struct);
+ identifierFieldIds.forEach(id -> validateIdentifierField(id, this.lazyIdToField(), idToParent));
+ }
+
this.identifierFieldIds = identifierFieldIds != null ? Ints.toArray(identifierFieldIds) : new int[0];
lazyIdToName();
}
+ protected static void validateIdentifierField(int fieldId, Map<Integer, Types.NestedField> idToField,
Review comment:
Why is this `protected`? Shouldn't it be package-private instead? I don't think that we intend to support subclasses of `Schema`.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org