aokolnychyi commented on code in PR #7685:
URL: https://github.com/apache/iceberg/pull/7685#discussion_r1201356865


##########
spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/source/SparkPositionDeltaWrite.java:
##########
@@ -435,7 +443,10 @@ public void delete(InternalRow metadata, InternalRow id) 
throws IOException {
 
       InternalRow partition = metadata.getStruct(partitionOrdinal, 
partitionRowWrapper.size());
       StructProjection partitionProjection = partitionProjections.get(specId);
-      partitionProjection.wrap(partitionRowWrapper.wrap(partition));
+
+      if (partitionProjection != null) {

Review Comment:
   What about adding a separate interface for partition projections? That way, 
we can avoid an extra if branch in the code that gets invoked in a tight loop. 
We would also handle other places. This PR updates DELETE commands but we have 
a similar problem in UPDATE and MERGE as those can write deletes against an 
upartitioned spec.
   
   ```
   interface PartitionProjection implements StructLike {
   
     PartitionProjection create(PartitionSpec spec, StructType 
commonPartitionType) {
       ...
     }
   
     PartitionProjection wrap(StructLike newStruct);
   
     private static class UnpartitionedSpecProjection implements 
PartitionProjection {
       // something always returns null
     }
   
     private static class PartitionedSpecProjection implements 
PartitionProjection {
       // something that delegates to StructProjection and uses 
spec.partitionType()
     }
   }
   ```
   
   The naming above is totally random.



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