rdblue commented on a change in pull request #2465:
URL: https://github.com/apache/iceberg/pull/2465#discussion_r615318360
##########
File path: core/src/main/java/org/apache/iceberg/SchemaUpdate.java
##########
@@ -317,6 +333,38 @@ public UpdateSchema unionByNameWith(Schema newSchema) {
return this;
}
+ @Override
+ public UpdateSchema addIdentifierField(String name) {
+ Types.NestedField field = schema.findField(name);
+ if (field == null) {
+ field = adds.get(TABLE_ROOT_ID).stream()
+ .filter(f -> f.name().equals(name))
+ .findAny().orElse(null);
+ }
+
+ Preconditions.checkArgument(field != null,
+ "Cannot find column of the given name in existing or newly added
columns: %s", name);
+ Preconditions.checkArgument(field.isRequired(),
+ "Cannot add column %s as an identifier field because it is not a
required field", name);
+ Preconditions.checkArgument(field.type().isPrimitiveType(),
+ "Cannot add column %s as an identifier field because it is not a
primitive field", name);
+ Preconditions.checkArgument(!identifierFieldNames.contains(name),
+ "Cannot add column %s as an identifier field because it already is",
name);
+ identifierFieldNames.add(name);
+ return this;
+ }
+
+ @Override
+ public UpdateSchema removeIdentifierField(String name) {
+ Types.NestedField field = schema.findField(name);
+ Preconditions.checkArgument(field != null,
+ "Cannot find column of name %s in existing columns of schema %s",
name, schema);
+ Preconditions.checkArgument(identifierFieldNames.contains(name),
+ "Cannot remove column from identifier fields %s because it is not an
identifier field", name);
Review comment:
Same comments here about using "because" and a long sentence instead of
a simple `:`.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]