Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Tables.dictcolumntable produces columns with #undef instead of missing in struct-valued columns #286

Closed
kleinschmidt opened this issue Aug 1, 2022 · 2 comments

Comments

@kleinschmidt
Copy link

kleinschmidt commented Aug 1, 2022

julia> using Tables

julia> struct SSS
           stuff
       end

julia> Tables.dictcolumntable([(; a=SSS(1)), (; b=2)]).a
2-element Vector{Union{Missing, SSS}}:
    SSS(1)
 #undef

julia> Tables.columns(Tables.dictrowtable([(; a=SSS(1)), (; b=2)]))
Tables.CopiedColumns{NamedTuple{(:a, :b), Tuple{Vector{Union{Missing, SSS}}, Vector{Union{Missing, Int64}}}}} with 2 rows, 2 columns, and schema:
 :a  Union{Missing, SSS}
 :b  Union{Missing, Int64}

julia> Tables.columns(Tables.dictrowtable([(; a=SSS(1)), (; b=2)])).a
2-element Vector{Union{Missing, SSS}}:
 SSS(1)
 missing

julia> Tables.dictcolumntable([(; a=1), (; b=2)]).a
2-element Vector{Union{Missing, Int64}}:
 1
  missing
@nalimilan
Copy link
Member

Looks like dictcolumntable assumes that missing is used instead of #undef, but that's only the case for bitstypes. And even worse, singleton types may be used as the default instead of missing, giving misleading results. So better initialize all the time the entry with missing.

@quinnj
Copy link
Member

quinnj commented Aug 28, 2022

Sorry for the slow response: #288

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants