-
Notifications
You must be signed in to change notification settings - Fork 827
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
Don't panic when creating Field
from FFI_ArrowSchema
with no name
#6251
Comments
Hi, I'd like to take this up. |
@ByteBaker sorry but it was only a one line change and I needed a git tag I could point to from my project, so I created #6273 |
I suppose the non-null assertion inside
I'm personally with 2 because it leaves the control with the user and the change is minimal (in addition to being C-spec compliant) what's your thoughts? |
@kylebarron sorry I had already typed and this message didn't sync up. But do you still wanna carry forward this discussion for a more permanent and agreed upon solution or should I delete the one above? |
It's good to have this discussion here. In #6273 I'm suggesting something like option 2. I think to be spec compliant, For reference, this is the same behavior as pyarrow, which defaults to an empty string when importing a null name to a Field: import pyarrow as pa
dt = pa.uint8()
field = pa.field(dt)
assert field.name == "" # passes |
So, the 3rd one, I suppose? |
My proposal is more in line with your number 2. |
Returning |
|
Describe the bug
When constructing a
Field
from anFFI_ArrowSchema
, it calls thename()
method:arrow-rs/arrow-schema/src/ffi.rs
Line 585 in 2461a16
That method asserts that name is not null:
arrow-rs/arrow-schema/src/ffi.rs
Line 265 in 2461a16
But according to the C Data Interface spec, it is allowed for the name to be null:
I would argue that this function should at least not panic on spec-valid input. It should either infer a blank name for that field or return
Option<&str>
.To Reproduce
I can try to provide a full rust repro case if necessary; the claimed bug should be clear without a full repro case.
Expected behavior
Expected not to panic.
Additional context
I hit this in my arro3 project, where I pass in a pyarrow
Schema
and try to reconstruct it on the Rust side as aField
. This is slightly simpler because I can directly get a singleDataType::Struct
with all fields, rather than accessing the fields of aSchema
and then passing that toDataType::Struct
. But since the pyarrow Schema doesn't set a name on the Arrow C Schema, this fails.Since they're communicating via a valid Arrow C Schema, I would argue this should work, and at least not panic.
The text was updated successfully, but these errors were encountered: