rdblue commented on code in PR #10678:
URL: https://github.com/apache/iceberg/pull/10678#discussion_r1701030165


##########
api/src/main/java/org/apache/iceberg/PartitionSpec.java:
##########
@@ -442,9 +456,10 @@ private Types.NestedField findSourceColumn(String 
sourceName) {
     Builder identity(String sourceName, String targetName) {
       Types.NestedField sourceColumn = findSourceColumn(sourceName);
       checkAndAddPartitionName(targetName, sourceColumn.fieldId());
+      String normalizedTargetName = caseSensitive ? targetName : 
targetName.toLowerCase();

Review Comment:
   I don't think this should normalize the target name. That could be passed by 
the caller and this should not modify it. I think it should continue to use the 
target name that was passed in.
   
   The problem isn't with this method, it is with this version of the method, 
it is with the `identity(String sourceName)` version that assumes it can pass 
the source name as the target name. One solution is to lower case the string 
there, but I would prefer to preserve the case from the schema instead.
   
   I think the easiest way to do that is to add a private identity method, like 
this:
   
   ```java
       Builder identity(String sourceName, String targetName) {
         return identity(findSourceColumn(sourceName), targetName);
       }
   
       Builder identity(String sourceName) {
         Types.NestedField sourceColumn = findSourceColumn(sourceName);
         return identity(sourceColumn, sourceColumn.name);
       }
   
       private Builder identity(String sourceColumn, String targetName) {
         checkAndAddPartitionName(targetName, sourceColumn.fieldId());
         PartitionField field =
             new PartitionField(
                 sourceColumn.fieldId(), nextFieldId(), targetName, 
Transforms.identity());
         checkForRedundantPartitions(field);
         fields.add(field);
         return this;
       }
   ```



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

Reply via email to