Hi
I want i have my data in Indexed tables and want to use Query.jl to make NDSparse tables for use in a creating a MIP model using JuMP.
However when i have created the NDSparse test as seen below, i can’t get the data out from it.
What am i doing wrong?
julia>visits
Table with 130 rows, 4 columns:
intID patientID bestord req_type
────────────────────────────────────────────────
1 1 38=>2019-02-07 "AEKG"
2 1 38=>2019-02-07 "Consultation"
3 1 38=>2019-02-07 "TTE"
....
julia> resources
Table with 7 rows, 7 columns:
Columns:
# colname type
──────────────────────────────────────
1 intID Int64
2 id String
3 type String
4 name String
5 qualifications Dict{String,String}
6 workpattern Calendar
7 calendar Calendar
test = @from v in visits begin
@join r in resources on v.req_type equals r.type into k
@select (test1= v.intID,test2= map(x->x.intID,k))
@collect NDSparse
end
julia> test
1-d NDSparse with 130 values (1 field named tuples):
test1 │ test2
──────┼──────────
1 │ [6]
2 │ [1, 2, 3]
3 │ [5]
4 │ [6]
...
julia> test[1]
ERROR: MethodError: no method matching get(::IndexedTables.var"#146#147"{Tuple{Int64}}, ::NDSparse{NamedTuple{(:test2,),Tuple{Array{Int64,1}}},Tuple{Int128},StructArrays.StructArray{NamedTuple{(:test1,),Tuple{Int128}},1,NamedTuple{(:test1,),Tuple{Array{Int128,1}}},Int64},StructArrays.StructArray{NamedTuple{(:test2,),Tuple{Array{Int64,1}}},1,NamedTuple{(:test2,),Tuple{Array{Array{Int64,1},1}}},Int64}}, ::Tuple{Int64})
Closest candidates are:
get(::REPL.Terminals.TTYTerminal, ::Any, ::Any) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\REPL\src\Terminals.jl:176
get(::IdDict{K,V}, ::Any, ::Any) where {K, V} at abstractdict.jl:596
get(::Union{Function, Type}, ::IdDict{K,V}, ::Any) where {K, V} at abstractdict.jl:651
...
Stacktrace:
[1] _getindex_scalar(::NDSparse{NamedTuple{(:test2,),Tuple{Array{Int64,1}}},Tuple{Int128},StructArrays.StructArray{NamedTuple{(:test1,),Tuple{Int128}},1,NamedTuple{(:test1,),Tuple{Array{Int128,1}}},Int64},StructArrays.StructArray{NamedTuple{(:test2,),Tuple{Array{Int64,1}}},1,NamedTuple{(:test2,),Tuple{Array{Array{Int64,1},1}}},Int64}}, ::Tuple{Int64}) at C:\Users\hebb\.julia\packages\IndexedTables\5U0Ap\src\indexing.jl:21
[2] _getindex(::NDSparse{NamedTuple{(:test2,),Tuple{Array{Int64,1}}},Tuple{Int128},StructArrays.StructArray{NamedTuple{(:test1,),Tuple{Int128}},1,NamedTuple{(:test1,),Tuple{Array{Int128,1}}},Int64},StructArrays.StructArray{NamedTuple{(:test2,),Tuple{Array{Int64,1}}},1,NamedTuple{(:test2,),Tuple{Array{Array{Int64,1},1}}},Int64}}, ::Tuple{Int64}) at C:\Users\hebb\.julia\packages\IndexedTables\5U0Ap\src\indexing.jl:18
[3] getindex(::NDSparse{NamedTuple{(:test2,),Tuple{Array{Int64,1}}},Tuple{Int128},StructArrays.StructArray{NamedTuple{(:test1,),Tuple{Int128}},1,NamedTuple{(:test1,),Tuple{Array{Int128,1}}},Int64},StructArrays.StructArray{NamedTuple{(:test2,),Tuple{Array{Int64,1}}},1,NamedTuple{(:test2,),Tuple{Array{Array{Int64,1},1}}},Int64}}, ::Int64) at C:\Users\hebb\.julia\packages\IndexedTables\5U0Ap\src\indexing.jl:15
[4] top-level scope at none:0