Open DrChainsaw opened 4 years ago
dff = DataFrame(a=1:3, b=3:5) #No problem with litterals: addcol(row) = merge(row, (;:c => 1)) dff |> @map(addcol(_)) |> DataFrame # But this fails: addcol(row, cname) = merge(row, (;cname => 1)) dff |> @map(addcol(_, :c)) |> DataFrame ERROR: MethodError: no method matching nondatavaluenamedtuple(::Type{NamedTuple}) Closest candidates are: nondatavaluenamedtuple(::Type{NT}) where {names, NT<:(NamedTuple{names,T} where T<:Tuple)} at C:\Users\echrska\.julia\packages\Tables\okt7x\src\tofromdatavalues.jl:2 Stacktrace: [1] schema(::Tables.IteratorWrapper{QueryOperators.EnumerableMap{NamedTuple,QueryOperators.EnumerableIterable{NamedTuple{(:a, :b),Tuple{Int64,Int64}},Tables.DataValueRowIterator{NamedTuple{(:a, :b),Tuple{Int64,Int64}},Tables.Schema{(:a, :b),Tuple{Int64,Int64}},Tables.RowIterator{NamedTuple{(:a, :b),Tuple{Array{Int64,1},Array{Int64,1}}}}}},var"#290#292"}}) at C:\Users\echrska\.julia\packages\Tables\okt7x\src\tofromdatavalues.jl:32 [2] columns at C:\Users\echrska\.julia\packages\Tables\okt7x\src\fallbacks.jl:237 [inlined] [3] DataFrame(::QueryOperators.EnumerableMap{NamedTuple,QueryOperators.EnumerableIterable{NamedTuple{(:a, :b),Tuple{Int64,Int64}},Tables.DataValueRowIterator{NamedTuple{(:a, :b),Tuple{Int64,Int64}},Tables.Schema{(:a, :b),Tuple{Int64,Int64}},Tables.RowIterator{NamedTuple{(:a, :b),Tuple{Array{Int64,1},Array{Int64,1}}}}}},var"#290#292"}; copycols::Bool) at C:\Users\echrska\.julia\packages\DataFrames\S3ZFo\src\other\tables.jl:40 [4] DataFrame(::QueryOperators.EnumerableMap{NamedTuple,QueryOperators.EnumerableIterable{NamedTuple{(:a, :b),Tuple{Int64,Int64}},Tables.DataValueRowIterator{NamedTuple{(:a, :b),Tuple{Int64,Int64}},Tables.Schema{(:a, :b),Tuple{Int64,Int64}},Tables.RowIterator{NamedTuple{(:a, :b),Tuple{Array{Int64,1},Array{Int64,1}}}}}},var"#290#292"}) at C:\Users\echrska\.julia\packages\DataFrames\S3ZFo\src\other\tables.jl:31 [5] |>(::QueryOperators.EnumerableMap{NamedTuple,QueryOperators.EnumerableIterable{NamedTuple{(:a, :b),Tuple{Int64,Int64}},Tables.DataValueRowIterator{NamedTuple{(:a, :b),Tuple{Int64,Int64}},Tables.Schema{(:a, :b),Tuple{Int64,Int64}},Tables.RowIterator{NamedTuple{(:a, :b),Tuple{Array{Int64,1},Array{Int64,1}}}}}},var"#290#292"}, ::Type{T} where T) at .\operators.jl:823 [6] top-level scope at none:0 # This too: @from r in dff begin @select addcol(r, :c) @collect DataFrame end ERROR: MethodError: no method matching nondatavaluenamedtuple(::Type{NamedTuple}) Closest candidates are: nondatavaluenamedtuple(::Type{NT}) where {names, NT<:(NamedTuple{names,T} where T<:Tuple)} at C:\Users\echrska\.julia\packages\Tables\okt7x\src\tofromdatavalues.jl:2 Stacktrace: [1] schema(::Tables.IteratorWrapper{QueryOperators.EnumerableMap{NamedTuple,QueryOperators.EnumerableIterable{NamedTuple{(:a, :b),Tuple{Int64,Int64}},Tables.DataValueRowIterator{NamedTuple{(:a, :b),Tuple{Int64,Int64}},Tables.Schema{(:a, :b),Tuple{Int64,Int64}},Tables.RowIterator{NamedTuple{(:a, :b),Tuple{Array{Int64,1},Array{Int64,1}}}}}},var"#297#298"}}) at C:\Users\echrska\.julia\packages\Tables\okt7x\src\tofromdatavalues.jl:32 [2] columns at C:\Users\echrska\.julia\packages\Tables\okt7x\src\fallbacks.jl:237 [inlined] [3] DataFrame(::QueryOperators.EnumerableMap{NamedTuple,QueryOperators.EnumerableIterable{NamedTuple{(:a, :b),Tuple{Int64,Int64}},Tables.DataValueRowIterator{NamedTuple{(:a, :b),Tuple{Int64,Int64}},Tables.Schema{(:a, :b),Tuple{Int64,Int64}},Tables.RowIterator{NamedTuple{(:a, :b),Tuple{Array{Int64,1},Array{Int64,1}}}}}},var"#297#298"}; copycols::Bool) at C:\Users\echrska\.julia\packages\DataFrames\S3ZFo\src\other\tables.jl:40 [4] DataFrame(::QueryOperators.EnumerableMap{NamedTuple,QueryOperators.EnumerableIterable{NamedTuple{(:a, :b),Tuple{Int64,Int64}},Tables.DataValueRowIterator{NamedTuple{(:a, :b),Tuple{Int64,Int64}},Tables.Schema{(:a, :b),Tuple{Int64,Int64}},Tables.RowIterator{NamedTuple{(:a, :b),Tuple{Array{Int64,1},Array{Int64,1}}}}}},var"#297#298"}) at C:\Users\echrska\.julia\packages\DataFrames\S3ZFo\src\other\tables.jl:31 [5] top-level scope at none:0 # But this works: DataFrame(@from r in dff begin @select addcol(r, :c) @collect end)