JuliaDatabases / JDBC.jl

Julia interface to Java database drivers
Other
38 stars 19 forks source link

Simple query fails after long runtime, ends up being a type error? #64

Open EMCP opened 1 year ago

EMCP commented 1 year ago

I am owner of a Trino server running V415 .. attempting to query it via Julialang.. and the HTTP api doesn't make much sense to me .. so I grabbed JDBC and attempted to query a simple select * from my_table .. but getting an error

here's the code

using JDBC
using Tables

driver_path = "/home/emcp/drivers/trino-jdbc-415.jar"

JDBC.usedriver(driver_path)
JDBC.init()

cnxn = JDBC.Connection("jdbc:trino://mytrino-server:8080/hive/my", props=Dict("user" => "hive")) # create connection
csr = cursor(cnxn) # create cursor from connection

# execute some SQL
execute!(csr, "SELECT * FROM my.table")

# Create a Vector of NamedTuples from the cursor rows
rows_data = NamedTuple.(collect(rows(csr)))

# Convert the rows vector to a Table.jl table
table = Tables(rows_data)

close(csr)

on the collect line it gives

ERROR: TypeError: in typeassert, expected Symbol, got a value of type Char
Stacktrace:
 [1] merge(a::NamedTuple{(), Tuple{}}, itr::Tuple{String, String, String, Int64, String, String, Dates.DateTime})
   @ Base ./namedtuple.jl:304
 [2] NamedTuple(itr::Tuple{String, String, String, Int64, String, String, Dates.DateTime})
   @ Base ./namedtuple.jl:123
 [3] _broadcast_getindex_evalf
   @ ./broadcast.jl:683 [inlined]
 [4] _broadcast_getindex
   @ ./broadcast.jl:656 [inlined]
 [5] getindex
   @ ./broadcast.jl:610 [inlined]
 [6] copy
   @ ./broadcast.jl:912 [inlined]
 [7] materialize(bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, Type{NamedTuple}, Tuple{Vector{Tuple{String, String, Any, Int64, String, String, Dates.DateTime}}}})
   @ Base.Broadcast ./broadcast.jl:873
 [8] top-level scope
   @ ~/Dev/git/emcp/julia_exploration/src/query_trino_JDBC.jl:17
EMCP commented 1 year ago

as others have remarked the performance was quite bad, but I understand the state of the project is that it's a last ditch sort of thing.. but thought it'd be worth posting this as it may be occurring for others when getting started