huaxingao commented on code in PR #14277:
URL: https://github.com/apache/iceberg/pull/14277#discussion_r2492932965


##########
spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/source/SparkPartitioningAwareScan.java:
##########
@@ -169,19 +177,82 @@ protected Set<PartitionSpec> specs() {
     return specs;
   }
 
+  private Object getPartitionValue(T task, String partitionFieldName) {
+    PartitionData partitionData = ((PartitionData) task.partition());
+    int pos = partitionData.getSchema().getField(partitionFieldName).pos();
+    return partitionData.get(pos);
+  }
+
+  private void performSplitOrdering(List<T> plannedTasks, Type partitionType) {
+    try {
+      // Use Iceberg's built-in type-safe comparator
+      Comparator<Object> comparator = Comparators.forType(partitionType);

Review Comment:
   If a partition field is identity on a nullable column, values can be null. 
Current compare may NPE. Wrap the comparator with a null-safe chain
   ```
       Comparator<Object> base = Comparators.forType(partitionType);
       Comparator<Object> comparator = 
org.apache.iceberg.types.Comparators.<Object>nullsFirst()
           .thenComparing(base);
   ```



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

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to