badalprasadsingh commented on code in PR #1214:
URL: https://github.com/apache/iceberg-go/pull/1214#discussion_r3529025140


##########
table/internal/utils.go:
##########
@@ -264,16 +268,12 @@ func (d *DataFileStatistics) ToDataFile(opts 
DataFileOpts) iceberg.DataFile {
        if !opts.Spec.Equals(*iceberg.UnpartitionedSpec) {
                fieldIDToPartitionData = make(map[int]any)
                for _, field := range opts.Spec.Fields() {
+                       // setting caller-supplied values
                        partitionVal := opts.PartitionValues[field.FieldID]
                        if partitionVal != nil {
-                               val := d.PartitionValue(field, opts.Schema)
-                               if val != nil {
-                                       fieldIDToPartitionData[field.FieldID] = 
val
-                               } else {
-                                       fieldIDToPartitionData[field.FieldID] = 
partitionVal
-                               }
+                               fieldIDToPartitionData[field.FieldID] = 
partitionVal
                        } else {
-                               fieldIDToPartitionData[field.FieldID] = nil
+                               fieldIDToPartitionData[field.FieldID] = 
d.PartitionValue(field, opts.Schema)

Review Comment:
   Done.
   
   Added inference on `field.Transform.PreservesOrder()`. So a caller value 
always wins, non-order-preserving transforms stay nil, and the `must(...)` 
panic is only reachable from `DataFileFromMetadata`, where the recover converts 
it to an error. Added the regression tests for it in `utils_test.go`.



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