Skip to content

append! doesn't follow AbstractArray interface, relies on Tables instead #278

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

Open
aplavin opened this issue Jun 27, 2023 · 1 comment
Open

Comments

@aplavin
Copy link
Member

aplavin commented Jun 27, 2023

Found a bug in the append! function of StructArrays:

julia> using AxisKeys, StructArrays

# OK:
julia> append!(StructArray(a=[1,2]), [(a=3,),(a=4,)])
4-element StructArray(::Vector{Int64}) with eltype NamedTuple{(:a,), Tuple{Int64}}:
...

# error:
julia> append!(StructArray(a=[1,2]), KeyedArray([(a=3,),(a=4,)], 1:2))
ERROR: type NamedTuple has no field a
@aplavin
Copy link
Member Author

aplavin commented Jul 4, 2023

I guess related to #270 (comment). Surely pushing/appending arrays shouldn't depend on Tables, right? This risks inconsistencies between the regular array and Table interfaces, and here we see a real-life example.

TBH, I didn't encounter it in the wild, but specifically crafted after looking how tables are incorporated in StructArrays. But I think this surely is a bug.

@aplavin aplavin changed the title Cannot append! KeyedArray to StructArray append! doesn't follow AbstractArray interface, relies on Tables instead Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant