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/09 00:44:54 UTC

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

rdblue commented on a change in pull request #619: Add schema validator
URL: https://github.com/apache/incubator-iceberg/pull/619#discussion_r344417103
 
 

 ##########
 File path: api/src/main/java/org/apache/iceberg/Schema.java
 ##########
 @@ -53,10 +54,24 @@
   public Schema(List<Types.NestedField> columns, Map<String, Integer> aliases) {
     this.struct = Types.StructType.of(columns);
     this.aliasToId = aliases != null ? ImmutableBiMap.copyOf(aliases) : null;
+
+    List<String> invalidFields = TypeUtil.validateFields(struct);
+    if (invalidFields.size() > 0) {
+      throw new ValidationException("Invalid Schema, please check fields: " +
+          Joiner.on(",").join(invalidFields.iterator()));
+    }
+
   }
 
   public Schema(List<Types.NestedField> columns) {
     this.struct = Types.StructType.of(columns);
+    List<String> invalidFields = TypeUtil.validateFields(struct);
+
+    if (invalidFields.size() > 0) {
+      throw new ValidationException("Invalid Schema, please check fields: " +
+          Joiner.on(",").join(invalidFields.iterator()));
 
 Review comment:
   Nit: missing a space in the separator after `,`.

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