laskoviymishka commented on code in PR #2637:
URL: https://github.com/apache/iceberg-go/pull/2637#discussion_r4640749678


##########
table/partition_statistics_write_test.go:
##########
@@ -320,6 +320,42 @@ func TestCollectPartitionStatisticsDecimalFromManifest(t 
*testing.T) {
        require.Equal(t, amount.Val, 
partition.Field(0).(*array.Decimal128).Value(0))
 }
 
+func TestCollectPartitionStatisticsPromotedIdentitySource(t *testing.T) {

Review Comment:
   Added in 17a886f264.



##########
table/internal/partition_aggregate.go:
##########
@@ -139,15 +140,33 @@ func CoercePartition(values map[int]any, partitionType 
*iceberg.StructType) map[
 
        coerced := make(map[int]any, partitionType.NumFields())
        for i := range partitionType.NumFields() {
-               id := partitionType.Field(i).ID
-               if value, ok := values[id]; ok {
-                       coerced[id] = value
+               field := partitionType.Field(i)
+               if value, ok := values[field.ID]; ok {
+                       coerced[field.ID] = widenPartitionValue(value, 
field.Type)
                }
        }
 
        return coerced
 }
 
+// widenPartitionValue applies the exact int to long and float to double
+// promotions, so values from manifests written before an identity source was
+// promoted aggregate with values written after it.
+func widenPartitionValue(value any, typ iceberg.Type) any {
+       switch v := value.(type) {
+       case int32:
+               if _, ok := typ.(iceberg.Int64Type); ok {
+                       return int64(v)
+               }
+       case float32:
+               if _, ok := typ.(iceberg.Float64Type); ok {
+                       return float64(v)
+               }

Review Comment:
   Thanks both, fixed in 6fca1bd. The end-to-end float to double test reading 
Files() and Partitions() is in 17a886f264.



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