This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-13
Channels
- # announcements (34)
- # aws (1)
- # beginners (99)
- # boot (19)
- # calva (26)
- # cider (24)
- # cljdoc (8)
- # cljs-dev (29)
- # clojure (107)
- # clojure-dev (3)
- # clojure-europe (12)
- # clojure-finland (1)
- # clojure-italy (24)
- # clojure-nl (5)
- # clojure-spec (13)
- # clojure-sweden (3)
- # clojure-uk (36)
- # clojurescript (4)
- # community-development (14)
- # cursive (3)
- # data-science (6)
- # datascript (57)
- # figwheel-main (3)
- # fulcro (9)
- # graalvm (11)
- # hoplon (18)
- # jobs (1)
- # jobs-discuss (2)
- # joker (10)
- # leiningen (13)
- # off-topic (23)
- # other-languages (1)
- # pathom (24)
- # pedestal (5)
- # re-frame (6)
- # reagent (45)
- # reitit (3)
- # rewrite-clj (1)
- # spacemacs (2)
- # sql (23)
- # tools-deps (6)
- # vim (5)
right - made a gist that exhibits the issue: https://gist.github.com/nha/763ef7f2dd404931809648925cca6e0f
@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?
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.
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.
OK, thanks. Seeing the actual code and the actual stacktrace will really help.
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;"]))
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.
Also, which version of Java are you running this on?
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]]}
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.
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
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?
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).
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.
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.
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.
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