Error creating table - KeyError: key String15 not found
DimitarVanguelov opened this issue · 0 comments
DimitarVanguelov commented
Trying to load a dataframe ingested with CSV.jl into SQL Server failed when using InlineString
s. Using stringtype=String
did not throw an error -- was able to load table -- though it did present other issues.
I'm on Windows 10 using VS Code with the Julia extension, version info is at the bottom. Here is the full stack trace from the InlineString
error:
┌ Warning: error creating table
│ (e, catch_backtrace()) =
│ KeyError: key String15 not found
│ Stacktrace:
│ [1] getindex
│ @ .\dict.jl:481 [inlined]
│ [2] sqltype(conn::ODBC.Connection, T::Type)
│ @ ODBC C:\Users\user\.julia\packages\ODBC\qhwMX\src\load.jl:35
│ [3] (::ODBC.var"#38#40"{ODBC.Connection})(T::Type)
│ @ ODBC .\none:0
│ [4] iterate
│ @ .\generator.jl:47 [inlined]
│ [5] collect_to!(dest::Vector{String}, itr::Base.Generator{Tuple{DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, Union, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, Union, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, DataType, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, DataType, DataType, Union, Union, Union, Union, Union, Union, Union, Union, Union, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType}, ODBC.var"#38#40"{ODBC.Connection}}, offs::Int64, st::Int64)
│ @ Base .\array.jl:782
│ [6] collect_to_with_first!
│ @ .\array.jl:760 [inlined]
│ [7] collect(itr::Base.Generator{Tuple{DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, Union,
DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, Union, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, DataType, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union, Union,
Union, Union, Union, Union, DataType, DataType, Union, Union, Union, Union, Union, Union, Union, Union, Union, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType, DataType}, ODBC.var"#38#40"{ODBC.Connection}})
│ @ Base .\array.jl:734
│ [8] createtable(conn::ODBC.Connection, nm::String, sch::Tables.Schema{(:run_dt, :prcs_dt, :evnt_dt, :evnt_typ_cd, :agmt_pkge_id, :holding_co_cd, :legal_ent, :trad_intsens_code, :closed_block_stat, :pgls_product_code, :spec_id, :prem_mode, :prem_mode_num, :liv_ben_sig, :non_forf_prv, :div_option, :spec_und_code, :lapse_dt, :aos_status_code, :admin_source_cd, :val_inforce_cls, :prod_issue_dt, :kind_code, :value_basis, :premium_basis, :conv_type, :conv_undrwrt_code, :plan_type, :pln_id, :db_opt_code, :lvl_prem_prd_num, :birth_dt, :issue_age, :extra_ratings, :imp_rating, :occ_rating, :smoking_habit, :pref_rating, :select_rating, :sex, :undw_class, :birth_dt_2nd, :issue_age_2nd, :extra_ratings_2nd, :imp_rating_2nd, :occ_rating_2nd, :smoking_habit_2nd, :pref_rating_2nd, :select_rating_2nd, :sex_2nd, :undw_class_2nd, :orig_agmt_pkge_id, :conv_type_detail, :orig_iss_age, :orig_term_issue_dt, :ild_plan_type, :channel, :key_acct, :ramm_eng_ln_rcmd, :ramm_proc_ind, :ramm_rndm_hldt_ind, :ramm_appr_typ, :iss_office_inforce, :cur_office_inforce, :iss_place_id, :iss_res_place_id, :cur_res_place_id, :xi_expiry_dt, :adr_status_dt, :adr_status, :settlement_status, :adr_claim_type_3, :adr_claim_disp_3, :adr_claim_score_3, :adr_app_rad_yr, :adr_app_path, :coli_ind, :fac_ind, :maturity, :dis_approve, :dis_eff, :no_lapse_guar, :shrt_trm_guar, :uemp_ben_start, :frst_uemp_prem_paid, :uemp_approve, :uemp_end, :base_face, :rdr_face, :misc_face, :layer, :pua, :var_extra, :scheduled_premium, :billed_premium, :current_total_premium, :limited_premium, :guideline_single_premium, :target_limited_nb_premium, :sales_load_premium, :short_term_premium, :lifetime_premium, :surrender_premium, :commissionable_target_premium, :seven_pay_premium, :coi_monthly_charge, :surrender_penalty, :current_accum_dividend, :total_dividend_liability, :fund_level_policy_ratio, :fund_level_policy_code, :phb_code, :total_accum_premium, :loan_amount, :preferred_loan_obl_fund_value, :int_loan_amount, :loan_repay, :interest_unpaid_loan_due, :gen_acct, :sep_acct, :loans_val_sys, :shaddow_acct, :cash_surrender_value, :tai_base_reins, :tai_rdr_reins, :tai_layer_reins), Tuple{Dates.Date, Dates.Date, Dates.Date, Int64, String15, String1,
String3, String1, Int64, String3, Int64, String1, Int64, String1, String1, Int64, String3, Union{Missing, Dates.Date}, String1, String1, String7, Dates.Date, String15, Int64, Int64, String1, String1, String3, String15, String1, Int64, Union{Missing, Dates.Date}, Int64, Int64, String3, Int64, String1, String1, String1, String1, Union{Missing, String1}, Union{Missing, Dates.Date}, Union{Missing, Int64}, Union{Missing, Int64}, Union{Missing, String3}, Union{Missing, Int64}, Union{Missing, String1}, Union{Missing, String1}, Union{Missing, String1}, Union{Missing, String1}, Union{Missing, String1}, Union{Missing, String15}, Union{Missing, String1}, Union{Missing, Int64}, Union{Missing, Dates.Date}, Union{Missing, String1}, String3, Union{Missing, String7}, Union{Missing, String3}, Union{Missing, String1}, Union{Missing, String1}, Union{Missing, String3}, Union{Missing, String7}, Union{Missing, String7}, Union{Missing, Int64}, Union{Missing, Int64}, Union{Missing, Int64}, Union{Missing, Dates.Date}, Union{Missing, Dates.Date}, Union{Missing, String1}, Union{Missing, String1}, Union{Missing, String1}, Union{Missing, String1}, Union{Missing, String1}, Union{Missing, Int64}, Union{Missing, String1}, Int64, Int64, Union{Missing, Dates.Date}, Union{Missing, Dates.Date}, Union{Missing, Dates.Date}, Union{Missing, Dates.Date}, Union{Missing, Dates.Date}, Union{Missing, Dates.Date}, Union{Missing, Dates.Date}, Union{Missing, Dates.Date}, Union{Missing, Dates.Date}, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64}}; debug::Bool, quoteidentifiers::Bool, createtableclause::String, columnsuffix::Dict{Any, Any})
│ @ ODBC C:\Users\user\.julia\packages\ODBC\qhwMX\src\load.jl:43
│ [9] load(itr::DataFrame, conn::ODBC.Connection, name::String; append::Bool, quoteidentifiers::Bool, debug::Bool, limit::Int64, kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│ @ ODBC C:\Users\user\.julia\packages\ODBC\qhwMX\src\load.jl:88
│ [10] top-level scope
│ @ .\timing.jl:220 [inlined]
│ [11] top-level scope
│ @ c:\Users\user\Programming\Julia\Data\sql_server_etl.jl:0
│ [12] eval
│ @ .\boot.jl:373 [inlined]
│ [13] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
│ @ Base .\loading.jl:1196
│ [14] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│ @ Base .\essentials.jl:716
│ [15] invokelatest(::Any, ::Any, ::Vararg{Any})
│ @ Base .\essentials.jl:714
│ [16] inlineeval(m::Module, code::String, code_line::Int64, code_column::Int64, file::String; softscope::Bool)
│ @ VSCodeServer c:\Users\user\.vscode\extensions\julialang.language-julia-1.4.3\scripts\packages\VSCodeServer\src\eval.jl:207
│ [17] (::VSCodeServer.var"#60#64"{Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
│ @ VSCodeServer c:\Users\user\.vscode\extensions\julialang.language-julia-1.4.3\scripts\packages\VSCodeServer\src\eval.jl:153
│ [18] withpath(f::VSCodeServer.var"#60#64"{Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
│ @ VSCodeServer c:\Users\user\.vscode\extensions\julialang.language-julia-1.4.3\scripts\packages\VSCodeServer\src\repl.jl:185
│ [19] (::VSCodeServer.var"#59#63"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
│ @ VSCodeServer c:\Users\user\.vscode\extensions\julialang.language-julia-1.4.3\scripts\packages\VSCodeServer\src\eval.jl:151
│ [20] hideprompt(f::VSCodeServer.var"#59#63"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
│ @ VSCodeServer c:\Users\user\.vscode\extensions\julialang.language-julia-1.4.3\scripts\packages\VSCodeServer\src\repl.jl:36
│ [21] (::VSCodeServer.var"#58#62"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
│ @ VSCodeServer c:\Users\user\.vscode\extensions\julialang.language-julia-1.4.3\scripts\packages\VSCodeServer\src\eval.jl:122
│ [22] with_logstate(f::Function, logstate::Any)
│ @ Base.CoreLogging .\logging.jl:511
│ [23] with_logger
│ @ .\logging.jl:623 [inlined]
│ [24] (::VSCodeServer.var"#57#61"{VSCodeServer.ReplRunCodeRequestParams})()
│ @ VSCodeServer c:\Users\user\.vscode\extensions\julialang.language-julia-1.4.3\scripts\packages\VSCodeServer\src\eval.jl:197
│ [25] #invokelatest#2
│ @ .\essentials.jl:716 [inlined]
│ [26] invokelatest(::Any)
│ @ Base .\essentials.jl:714
│ [27] macro expansion
│ @ c:\Users\user\.vscode\extensions\julialang.language-julia-1.4.3\scripts\packages\VSCodeServer\src\eval.jl:34 [inlined]
│ [28] (::VSCodeServer.var"#55#56")()
│ @ VSCodeServer .\task.jl:411
└ @ ODBC C:\Users\user\.julia\packages\ODBC\qhwMX\src\load.jl:90
ERROR: LoadError: MethodError: Cannot `convert` an object of type
Vector{Union{Missing, String15}} to an object of type
Union{Vector{ODBC.API.SQLTime}, Vector{Union{Missing, ODBC.API.SQLTime}}, Vector{Union{Missing, ODBC.API.SQLTimestamp}}, Vector{Union{Missing, ODBC.API.SQLDate}}, Vector{Union{Missing, Bool}}, Vector{Union{Missing, Int64}}, Vector{Union{Missing, Int32}}, Vector{Union{Missing, Int16}}, Vector{Union{Missing, Int8}}, Vector{Union{Missing, Float64}}, Vector{ODBC.API.SQLDate}, Vector{ODBC.API.SQLTimestamp}, Vector{Missing}, Vector{Union{Missing, Float32}}, Vector{Base.UUID}, Vector{Bool}, Vector{Float32}, Vector{Float64}, Vector{Int16}, Vector{Int32}, Vector{Int64}, Vector{Int8}, Vector{Union{Missing, Base.UUID}}, Vector{UInt8}, String}
Closest candidates are:
convert(::Type{T}, ::T) where T at C:\Users\user\AppData\Local\Programs\Julia-1.7.0-rc2\share\julia\base\essentials.jl:218
Stacktrace:
[1] ODBC.Buffer(x::String15)
@ ODBC C:\Users\user\.julia\packages\ODBC\qhwMX\src\utils.jl:114
[2] ODBC.Binding(stmt::ODBC.API.Handle, x::String15, i::Int64)
@ ODBC C:\Users\user\.julia\packages\ODBC\qhwMX\src\utils.jl:251
[3] (::ODBC.var"#5#6"{ODBC.API.Handle})(::Tuple{Int64, String15})
@ ODBC .\none:0
[4] iterate
@ .\generator.jl:47 [inlined]
[5] collect_to!(dest::Vector{ODBC.Binding}, itr::Base.Generator{Base.Iterators.Enumerate{Tables.Row{DataFrameRow{DataFrame, DataFrames.Index}}}, ODBC.var"#5#6"{ODBC.API.Handle}}, offs::Int64, st::Tuple{Int64, Int64})
@ Base .\array.jl:782
[6] collect_to_with_first!
@ .\array.jl:760 [inlined]
[7] collect(itr::Base.Generator{Base.Iterators.Enumerate{Tables.Row{DataFrameRow{DataFrame, DataFrames.Index}}}, ODBC.var"#5#6"{ODBC.API.Handle}})
@ Base .\array.jl:734
[8] bindparams
@ C:\Users\user\.julia\packages\ODBC\qhwMX\src\utils.jl:290 [inlined]
[9] execute(stmt::ODBC.Statement, params::Tables.Row{DataFrameRow{DataFrame, DataFrames.Index}}; debug::Bool, kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ ODBC C:\Users\user\.julia\packages\ODBC\qhwMX\src\dbinterface.jl:162
[10] (::ODBC.var"#46#47"{Bool, Int64, ODBC.Connection})()
@ ODBC C:\Users\user\.julia\packages\ODBC\qhwMX\src\load.jl:102
[11] transaction(f::ODBC.var"#46#47"{Bool, Int64, ODBC.Connection}, conn::ODBC.Connection)
@ ODBC C:\Users\user\.julia\packages\ODBC\qhwMX\src\load.jl:112
[12] load(itr::DataFrame, conn::ODBC.Connection, name::String; append::Bool, quoteidentifiers::Bool, debug::Bool, limit::Int64, kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ ODBC C:\Users\user\.julia\packages\ODBC\qhwMX\src\load.jl:96
[13] top-level scope
@ .\timing.jl:220 [inlined]
[14] top-level scope
@ c:\Users\user\Programming\Julia\Data\sql_server_etl.jl:0
in expression starting at c:\Users\user\Programming\Julia\Data\sql_server_etl.jl:14
Julia Version 1.7.0-rc2
Commit f23fc0d27a (2021-10-20 12:45 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, skylake-avx512)
Environment:
JULIA_EDITOR = code
JULIA_NUM_THREADS = 8
CSV v0.9.10
DataFrames v1.2.2
ODBC v1.0.4