-
Notifications
You must be signed in to change notification settings - Fork 5
fix(parquet): Handle uint32 to uint64 array widening in reverseTransformArray #721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,8 @@ func reverseTransformArray(dt arrow.DataType, arr arrow.Array) arrow.Array { | |
| return reverseTransformTime64(dt.(*arrow.Time64Type), arr) | ||
| case *array.Date32: | ||
| return reverseTransformFromDate32(dt, arr) | ||
| case *array.Uint32: | ||
| return reverseTransformFromUint32(dt, arr) | ||
| case *array.Struct: | ||
| dt := dt.(*arrow.StructType) | ||
| children := make([]arrow.ArrayData, arr.NumField()) | ||
|
|
@@ -100,6 +102,23 @@ func reverseTransformArray(dt arrow.DataType, arr arrow.Array) arrow.Array { | |
| } | ||
| } | ||
|
|
||
| func reverseTransformFromUint32(dt arrow.DataType, arr *array.Uint32) arrow.Array { | ||
| switch dt { | ||
| case arrow.PrimitiveTypes.Uint64: | ||
| builder := array.NewUint64Builder(memory.DefaultAllocator) | ||
| for i := 0; i < arr.Len(); i++ { | ||
| if arr.IsNull(i) { | ||
| builder.AppendNull() | ||
| continue | ||
| } | ||
| builder.Append(uint64(arr.Value(i))) | ||
| } | ||
| return builder.NewArray() | ||
|
Comment on lines
+105
to
+116
|
||
| default: | ||
| panic(fmt.Errorf("unsupported conversion from %s to %s", arr.DataType(), dt)) | ||
| } | ||
| } | ||
|
|
||
| func reverseTransformFromString(dt arrow.DataType, arr arrow.Array) arrow.Array { | ||
| builder := array.NewBuilder(memory.DefaultAllocator, dt) | ||
| for i := 0; i < arr.Len(); i++ { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverseTransformFromUint32matchesdtusing direct interface equality (case arrow.PrimitiveTypes.Uint64). This will fail if the incoming schema uses a different*arrow.Uint64Typeinstance (pointer-inequality), causing an unexpected panic even though the logical type is uint64. Prefer a type switch ondt.(type)(likereverseTransformFromDate32) or usearrow.TypeEqual(dt, arrow.PrimitiveTypes.Uint64)for the match.