Fork me on GitHub
#sql
<
2019-05-13
>
nha11:05:21

I may open a bug with facebook then, as I can’t see a way around it for now

seancorfield16:05:30

@nha That gist just shows calling bean fails -- that's unrelated to clojure.java.jdbc, right? What actual JDBC code is failing when you use Presto? And what is the stack trace?

nha16:05:48

It can fail for a number of reasons - bad query syntax, empty columns etc. (not at my computer to test at the moment). It doesn’t preclude using clojure.java.jdbc per se - but any error becomes an IllegalAccessException with little information attached.

nha16:05:52

I will see if I can get a more complete stacktrace at home. I don’t think it is related to clojure.java.jdbc other than it did pop up when trying to make presto work with clojure.

seancorfield17:05:35

OK, thanks. Seeing the actual code and the actual stacktrace will really help.

nha20:05:53

here is the stacktrace https://gist.github.com/nha/c45dc63cf971be4e5ccaf614f05b5a7e Not very helpful as-is. I now remember digging and couldn’t find what was calling bean in the first place. As for the code, any “wrong” statement will do:

(println (jdbc/execute! sql-conn ["any rubbish will do;"]))

seancorfield21:05:53

The exception is coming from Aviso's pretty-stack-printer, which is used by Boot to display an exception. I would try using clojure / clj and deps.edn here and see if you can get the raw stacktrace from the Presto failure instead. Or wrap your code in try/`catch` and call Throwable->map on the thrown exception and print it as raw data.

seancorfield21:05:16

Also, which version of Java are you running this on?

nha11:05:35

Throwable->map seems like a reasonable workaround for now.

(try
          ;; setting up the presto server is not something I can provide easily though
          (with-open [sql-conn (jdbc/get-connection (jdbc/get-datasource {:dbtype "presto"
                                                                          :dbname "test"
                                                                          :classname "com.facebook.presto.PrestoDriver"
                                                                          :port 8081
                                                                          :host "127.0.0.1"
                                                                          :user "admin"}))]
            (println (jdbc/execute! sql-conn ["show catalogs;"])))
          (catch Exception ex
            (Throwable->map ex)))
;; {:cause "line 1:38: mismatched input ';'. Expecting: 'LIKE', <EOF>", :via [{:type java.sql.SQLException, :message "Query failed (#20190512_211107_00142_38vp7): line 1:38: mismatched input ';'. Expecting: 'LIKE', <EOF>", :at [com.facebook.presto.jdbc.PrestoResultSet resultsException "PrestoResultSet.java" 1840]} {:type com.facebook.presto.jdbc.internal.client.FailureInfo$FailureException, :message "line 1:38: mismatched input ';'. Expecting: 'LIKE', <EOF>", :at [com.facebook.presto.sql.parser.ErrorHandler syntaxError "ErrorHandler.java" 92]}], :trace [[com.facebook.presto.sql.parser.ErrorHandler syntaxError "ErrorHandler.java" 92] [org.antlr.v4.runtime.ProxyErrorListener syntaxError "ProxyErrorListener.java" 41] [org.antlr.v4.runtime.Parser notifyErrorListeners "Parser.java" 540] [org.antlr.v4.runtime.DefaultErrorStrategy reportUnwantedToken "DefaultErrorStrategy.java" 351] [org.antlr.v4.runtime.DefaultErrorStrategy singleTokenDeletion "DefaultErrorStrategy.java" 515] [org.antlr.v4.runtime.DefaultErrorStrategy sync "DefaultErrorStrategy.java" 240] [com.facebook.presto.sql.parser.SqlBaseParser statement "SqlBaseParser.java" 2370] [com.facebook.presto.sql.parser.SqlBaseParser statement "SqlBaseParser.java" 2681] [com.facebook.presto.sql.parser.SqlBaseParser singleStatement "SqlBaseParser.java" 235] [com.facebook.presto.sql.parser.SqlParser invokeParser "SqlParser.java" 140] [com.facebook.presto.sql.parser.SqlParser createStatement "SqlParser.java" 93] [com.facebook.presto.execution.SqlQueryManager getQueryType "SqlQueryManager.java" 517] [com.facebook.presto.execution.SqlQueryManager createQueryInternal "SqlQueryManager.java" 419] [com.facebook.presto.execution.SqlQueryManager lambda$createQuery$3 "SqlQueryManager.java" 377] [java.util.concurrent.Executors$RunnableAdapter call "Executors.java" 511] [java.util.concurrent.FutureTask run "FutureTask.java" 266] [java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1149] [java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 624] [java.lang.Thread run "Thread.java" 748]]}

nha11:05:48

(unreadable here - adding to the gist)

nha11:05:41

happy to use Throwable->map for the time being, it provides enough information

curtosis17:05:02

has anyone worked with a server-side jdbc library? as in, I have a custom app that want to look like a SQL database. (like Sybase OpenServer, for the other 6 people in the world who have used it.) So far, searching on “sql server jdbc” is… unhelpful.

gklijs17:05:54

No, but sounds a bit like KSQL, as in that's also a java application that accepts a SQL-like syntax. https://github.com/confluentinc/ksql

curtosis18:05:41

I think that’s a much bigger architectural commitment. 🙂

seancorfield19:05:25

Sounds like you'd want to implement the JDBC spec, or at least a subset of it, and that's a massive undertaking. Can you explain a bit about why you want to do this?

curtosis23:05:55

The easy summary is I have a custom datastore — more or less Datomic with a bunch of logic on top of it — and I need to make it accessible to JDBC tools. (via various projections into “tables”, of course).

curtosis23:05:00

That was the beauty of Sybase OpenServer — it handled all the client/server spec and you just had to interpret and feed it back a set of rows.

curtosis23:05:45

With a little bit of digging this afternoon, it looks like Apache Calcite may be the right tool to get me started, though I haven’t seen anyone try it from Clojure.

seancorfield23:05:01

Oh, that does sound interesting! If you go down that path, please keep us posted here, and let me know if anything in clojure.java.jdbc or next.jdbc blocks you from working with that.

👍 4
hiredman17:05:22

https://github.com/hiredman/agilezen-jdbc/blob/master/src/agilezen_jdbc/core.clj is a thing I wrote a long time ago to use jdbc to query agilezen's (a ticket tracker) rest api

hiredman17:05:52

the really annoying bit is to be a jdbc driver you have to parse sql