prodeezy commented on a change in pull request #498: Adding partition transform
builder methods to set custom target field names
URL: https://github.com/apache/incubator-iceberg/pull/498#discussion_r328903596
##########
File path: api/src/main/java/org/apache/iceberg/PartitionSpec.java
##########
@@ -331,7 +331,11 @@ private Builder(Schema schema) {
this.schema = schema;
}
- private void checkAndAddPartitionName(String name) {
+ private void checkAndAddPartitionName(String name, String transform) {
+ if (!transform.equalsIgnoreCase("identity")) {
Review comment:
Done. Only change I made to your logic is I handled both cases in separate
if-else condition blocks as the identity case is unique from the other
transform cases.
```
Types.NestedField schemaField = schema.findField(name);
if (identitySourceColumnId != null) {
// for identity transform case we allow conflicts between partition
and schema field name as
// long as they are sourced from the same schema field
Preconditions.checkArgument(schemaField == null ||
schemaField.fieldId() == identitySourceColumnId,
"Cannot create identity partition not sourced from same field in
schema: %s", name);
} else {
// for all other transforms we don't allow conflicts between
partition name and schema field name
Preconditions.checkArgument(schemaField == null,
"Cannot create partition from name that exists in schema: %s",
name);
}
Preconditions.checkArgument(name != null && !name.isEmpty(),
"Cannot use empty or null partition name: %s", name);
Preconditions.checkArgument(!partitionNames.contains(name),
"Cannot use partition name more than once: %s", name);
partitionNames.add(name);
}
```
----------------------------------------------------------------
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]