diff --git a/modules/drivers/presto-jdbc/src/metabase/driver/presto_jdbc.clj b/modules/drivers/presto-jdbc/src/metabase/driver/presto_jdbc.clj index 62a6ba10eb40e96b0e525ead4192ef9f772af61f..6e839fbc128143a7bcf9a821e29fb7edde846b49 100644 --- a/modules/drivers/presto-jdbc/src/metabase/driver/presto_jdbc.clj +++ b/modules/drivers/presto-jdbc/src/metabase/driver/presto_jdbc.clj @@ -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] diff --git a/modules/drivers/presto-jdbc/test/metabase/driver/presto_jdbc_test.clj b/modules/drivers/presto-jdbc/test/metabase/driver/presto_jdbc_test.clj index a32aac1d2c030412767fff0020a5d636575b0464..c66b9d0b702ef946310295dbfd6b6f8b7513f334 100644 --- a/modules/drivers/presto-jdbc/test/metabase/driver/presto_jdbc_test.clj +++ b/modules/drivers/presto-jdbc/test/metabase/driver/presto_jdbc_test.clj @@ -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)))))))