rdblue commented 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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to