JuliaData / JuliaData/TypedTables.jl
append! NamedTuple to Table lead to strange behavior
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 152
- Forks
- 26
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I was trying to append! a NamedTuple to Table... and noticed this odd behiavor
julia> t = Table(a = [1, 2, 3], b = [2.0, 4.0, 6.0])
Table with 2 columns and 3 rows:
a b
┌───────
1 │ 1 2.0
2 │ 2 4.0
3 │ 3 6.0
julia> append!(t, (a=4, b=8.0))
ERROR: MethodError: Cannot `convert` an object of type Int64 to an object of type @NamedTuple{a::Int64, b::Float64}
Closest candidates are:
convert(::Type{NT}, ::NT) where {names, T<:Tuple, NT<:NamedTuple{names, T}}
@ Base namedtuple.jl:184
convert(::Type{T}, ::T) where T
@ Base Base.jl:84
convert(::Type{NT}, ::NamedTuple{names}) where {names, T<:Tuple, NT<:NamedTuple{names, T}}
@ Base namedtuple.jl:186
...
Stacktrace:
[1] setindex!
@ C:\Users\femto\.julia\packages\TypedTables\ItVth\src\Table.jl:142 [inlined]
[2] _append!
@ .\array.jl:1201 [inlined]
[3] append!(a::Table{@NamedTuple{…}, 1, @NamedTuple{…}}, iter::@NamedTuple{a::Int64, b::Float64})
@ Base .\array.jl:1187
[4] top-level scope
@ REPL[31]:1
Some type information was truncated. Use `show(err)` to see complete types.
julia> t
Table with 2 columns and 5 rows:
a b
┌────────────
1 │ 1 2.0
2 │ 2 4.0
3 │ 3 6.0
4 │ 3 1.0e-323
5 │ 3 1.0e-323
These 2 rows are intriguing
4 │ 3 1.0e-323
5 │ 3 1.0e-323
Any idea what is causing that?
Would it be possible to append! a NamedTuple to a Table (without creating a Table from NamedTuple)
Kind regards
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Julia REPL example, then start at src/Table.jl line 142 from the stack trace and follow the append! path. Done means appending the NamedTuple directly either works as requested or fails without partially corrupting the table, with the observed behavior explained.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100