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 2019/11/14 06:57:41 UTC

[GitHub] [incubator-iceberg] chenjunjiedada commented on a change in pull request #619: Add schema validator

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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org