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


##########
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:
   not new, same cause: after a float -> double promotion, every other inspect 
table with a partition column fails with `cannot append scalar of type float32 
to builder for type float64`
   
   a `Float64Type` case in PartitionValueScalar fixes all



##########
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:
   the inspect.Partitions test can go in now as #2631 is merged
   
   lets mirror this test in "table/inspect" with 
"inspectTableWithManifestListAndSchemas": one case with only the old manifest 
(two files, the single-manifest path), one with old plus new, lets also Include 
the float to double case, which fails on main today



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