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:55:29 UTC

[GitHub] [incubator-iceberg] rdblue edited a comment on issue #619: Add schema validator

rdblue edited a comment on issue #619: Add schema validator
URL: https://github.com/apache/incubator-iceberg/pull/619#issuecomment-552047058
 
 
   I think this is actually easier to implement than the version here. Instead of running a new validator class, I think you can add this validation to the existing `IndexByName` class. Just change `addField` to include the validation:
   
   ```java
     private void addField(String name, int fieldId) {
       String fullName = name;
       if (!fieldNames().isEmpty()) {
         fullName = DOT.join(DOT.join(fieldNames().descendingIterator()), name);
       }
   
       Integer existingFieldId = nameToId.put(fullName, fieldId);
       if (existingFieldId != null) {
         throw new ValidationException(
             "Invalid schema: multiple fields for name %s: %s and %s", fullName, existingFieldId, fieldId);
       }
     }
   ```
   
   Then all you'd need to do is to access `lazyNameToId()` in the constructor.

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