badalprasadsingh commented on code in PR #2487:
URL: https://github.com/apache/iceberg-go/pull/2487#discussion_r4737123797
##########
table/arrow_utils.go:
##########
@@ -1549,6 +1571,34 @@ func toRequestedSchema(ctx context.Context, requested,
fileSchema *iceberg.Schem
return out, nil
}
+// convertPartitionConstants widens each constant to the type its field has in
+// the requested schema: a manifest keeps the partition type the file was
+// written with, so a field promoted since still carries the narrower value.
+// It returns constants itself when there are none, and otherwise allocates a
+// new map per call, which is once per record batch.
+func convertPartitionConstants(requested *iceberg.Schema, constants
map[int]any) (map[int]any, error) {
Review Comment:
we are converting every identity value, even for cols the file stores, so
something it cannot convert, for e.g., one that another engine wrote, fails a
scan that works on main right now
better: it we could skip stored cols
##########
table/arrow_utils.go:
##########
@@ -1334,7 +1338,12 @@ func (a *arrowProjectionVisitor) Struct(st
iceberg.StructType, structArr arrow.A
}
alloc := compute.GetAllocator(a.ctx)
+ constant, hasConstant := a.partitionConstants[field.ID]
switch {
+ case hasConstant && constant != nil:
+ arr = defaultToArray(constant, field.Type, dt,
structArr.Len(), alloc)
+ case hasConstant && (!field.Required ||
a.allowMissingRequired):
+ arr = array.MakeArrayOfNull(alloc, dt,
structArr.Len())
Review Comment:
lets add tests coverting this: an un-convertible partition value is an error
naming the column, and a null partition value on a required column is rejected
--
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]