Skip to content
Snippets Groups Projects
Unverified Commit 7285e3d4 authored by Jeff Evans's avatar Jeff Evans Committed by GitHub
Browse files

Fix Presto JDBC connection error (#17293)

Remove the `driver/can-connect?` implementation and move the `select-keys` logic instead to the existing place in `sql-jdbc.conn/connection-details->spec`

Update test to also include the `:let-user-control-scheduling` details entry
parent f9600ead
No related merge requests found
......@@ -224,7 +224,17 @@
(Integer/parseInt port)
port)))
(assoc :SSL ssl?)
(dissoc :ssl))]
;; remove any Metabase specific properties that are not recognized by the PrestoDB JDBC driver, which is
;; very picky about properties (throwing an error if any are unrecognized)
;; all valid properties can be found in the JDBC Driver source here:
;; https://github.com/prestodb/presto/blob/master/presto-jdbc/src/main/java/com/facebook/presto/jdbc/ConnectionProperties.java
(select-keys [:host :port :catalog :schema :additional-options ; needed for [jdbc-spec]
;; JDBC driver specific properties
:user :password :socksProxy :httpProxy :applicationNamePrefix :disableCompression :SSL
:SSLKeyStorePath :SSLKeyStorePassword :SSLTrustStorePath :SSLTrustStorePassword
:KerberosRemoteServiceName :KerberosPrincipal :KerberosUseCanonicalHostname
:KerberosConfigPath :KerberosKeytabPath :KerberosCredentialCachePath :accessToken
:extraCredentials :sessionProperties :protocols :queryInterceptors]))]
(jdbc-spec props)))
;;; +----------------------------------------------------------------------------------------------------------------+
......@@ -333,10 +343,6 @@
(log/debug e (trs "Error setting statement fetch direction to FETCH_FORWARD"))))
stmt))
(defmethod driver/can-connect? :presto-jdbc
[driver details]
(sql-jdbc.conn/can-connect? driver (dissoc details :engine)))
(defn- ^PrestoConnection pooled-conn->presto-conn
"Unwraps the C3P0 `pooled-conn` and returns the underlying `PrestoConnection` it holds."
[^C3P0ProxyConnection pooled-conn]
......
......@@ -194,5 +194,9 @@
(deftest test-database-connection-test
(mt/test-driver :presto-jdbc
(testing "can-test-database-connection works"
(is (nil? (database-api/test-database-connection :presto-jdbc (:details (mt/db))))))))
(testing "can-test-database-connection works properly"
;; for whatever reason, :let-user-control-scheduling is the only "always available" option that goes into details
;; the others (ex: :auto_run_queries and :refingerprint) are one level up (fields in the model, not in the details
;; JSON blob)
(let [db-details (assoc (:details (mt/db)) :let-user-control-scheduling false)]
(is (nil? (database-api/test-database-connection :presto-jdbc db-details)))))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment