RussellSpitzer commented on code in PR #12897: URL: https://github.com/apache/iceberg/pull/12897#discussion_r2060493653
########## api/src/main/java/org/apache/iceberg/PartitionSpec.java: ########## @@ -601,17 +601,26 @@ public Builder alwaysNull(String sourceName) { // add a partition field with an auto-increment partition field id starting from // PARTITION_DATA_ID_START + Builder add(List<Integer> sourceIds, String name, Transform<?, ?> transform) { + return add(sourceIds, nextFieldId(), name, transform); + } + Builder add(int sourceId, String name, Transform<?, ?> transform) { - return add(sourceId, nextFieldId(), name, transform); + return add(List.of(sourceId), name, transform); } - Builder add(int sourceId, int fieldId, String name, Transform<?, ?> transform) { - checkAndAddPartitionName(name, sourceId); - fields.add(new PartitionField(sourceId, fieldId, name, transform)); + Builder add(List<Integer> sourceIds, int fieldId, String name, Transform<?, ?> transform) { + // we use the first entry in the source-ids list here + checkAndAddPartitionName(name, sourceIds.get(0)); Review Comment: The current logic looks like ```java if (check conflicts). { if identity { make sure we aren't using a different field name for this identity transform } else { make sure we aren't matching any other column name } } Make sure it's not empty Make sure we haven't already used this name for another partition Add partition ``` I have no idea why those last 2 checks aren't part of the "if check conflicts" branch Anyyyyyyway. I think this whole validation probably should be rewritten. The first branch we are checking basically based a lot of implicit assumptions when we should just be passing in the transform. But we don't have to do any of that now. For now I think we should pass in sourceIds and just have the first branch include a "if sourceIds.length == 1" -- 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. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org