chenjunjiedada commented on a change in pull request #619: Add schema validator
URL: https://github.com/apache/incubator-iceberg/pull/619#discussion_r346150660
##########
File path: api/src/main/java/org/apache/iceberg/Schema.java
##########
@@ -54,10 +54,14 @@
public Schema(List<NestedField> columns, Map<String, Integer> aliases) {
this.struct = StructType.of(columns);
this.aliasToId = aliases != null ? ImmutableBiMap.copyOf(aliases) : null;
+
+ // validate the schema through IndexByName visitor
+ TypeUtil.indexByName(struct);
Review comment:
Since lazyNameToId has one more check for uniqueness for value, some unit
tests failed due to they don't have unique field ID such as `testMixedTypes`.
And I think the lazy initialization is not lazy if we put it in a constructor
since `NameToId` is always null when constructing. So can we just call
IndexByName in constructor? It would be an easy way.
----------------------------------------------------------------
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]