-
Notifications
You must be signed in to change notification settings - Fork 139
fix(arrow/extensions): reject Null Variant typed_value #1243
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -225,6 +225,10 @@ func NewVariantType(storage arrow.DataType) (*VariantType, error) { | |
| dt = dt.(arrow.ExtensionType).StorageType() | ||
| } | ||
|
|
||
| if dt.ID() == arrow.NULL { | ||
| return nil, fmt.Errorf("%w: typed_value field must not be null type", arrow.ErrInvalid) | ||
| } | ||
|
|
||
| if nt, ok := dt.(arrow.NestedType); ok { | ||
| if !validNestedType(nt) { | ||
| return nil, fmt.Errorf("%w: typed_value field must be a valid nested type, got %s", arrow.ErrInvalid, typedValueField.Type) | ||
|
|
@@ -295,7 +299,10 @@ func validStruct(s *arrow.StructType) bool { | |
| switch s.NumFields() { | ||
| case 1: | ||
| f := s.Field(0) | ||
| return (f.Name == "value" && isBinary(f.Type)) || f.Name == "typed_value" | ||
| if f.Name == "value" { | ||
| return isBinary(f.Type) | ||
| } | ||
| return f.Name == "typed_value" && f.Type.ID() != arrow.NULL | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checking only |
||
| case 2: | ||
| valField, ok := s.FieldByName("value") | ||
| if !ok || !valField.Nullable || !isBinary(valField.Type) { | ||
|
|
@@ -311,7 +318,7 @@ func validStruct(s *arrow.StructType) bool { | |
| return validNestedType(nt) | ||
| } | ||
|
|
||
| return true | ||
| return typedField.Type.ID() != arrow.NULL | ||
| default: | ||
| return false | ||
| } | ||
|
|
||
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.
This new rejection makes
NewShreddedVariantType(arrow.Null)silently returnnil, because that constructor discards the error returned byNewVariantType. Normal use of the returned type then panics. Please handlearrow.Nullwith a valid non-nil representation or expose an error-returning construction path instead of discarding the validation failure.