|
2 | 2 | (:require [clojure.java.jdbc :as jdbc] |
3 | 3 | [clojure.string :as str] |
4 | 4 | [medley.core :as m] |
| 5 | + [metabase.connection-pool :as connection-pool] |
5 | 6 | [metabase.driver :as driver] |
| 7 | + [metabase.driver.sql-jdbc |
| 8 | + [common :as sql-jdbc.common]] |
6 | 9 | [metabase.driver.sql-jdbc.connection :as sql-jdbc.conn] |
7 | 10 | [metabase.driver.sql-jdbc.execute :as sql-jdbc.execute] |
8 | 11 | [metabase.driver.sql-jdbc.sync :as sql-jdbc.sync] |
|
11 | 14 | [metabase.driver.sql.util.unprepare :as unprepare] |
12 | 15 | [metabase.mbql.util :as mbql.u] |
13 | 16 | [metabase.query-processor.util :as qp.util]) |
14 | | - (:import [java.sql Connection ResultSet])) |
| 17 | + (:import |
| 18 | + (java.sql Connection ResultSet))) |
15 | 19 |
|
16 | 20 | (set! *warn-on-reflection* true) |
17 | 21 |
|
18 | 22 | (driver/register! :databricks-sql, :parent :sql-jdbc) |
19 | 23 |
|
| 24 | +(defn- sparksql-databricks |
| 25 | + "Create a database specification for a Spark SQL database." |
| 26 | + [{:keys [host db jdbc-flags] :as opts}] |
| 27 | + (merge |
| 28 | + {:classname "metabase.driver.FixedDatabricksDriver" |
| 29 | + :subprotocol "databricks" |
| 30 | + :subname (str "//" host ":443/" db jdbc-flags)} |
| 31 | + (dissoc opts :host :db :jdbc-flags))) |
| 32 | + |
20 | 33 | (defmethod sql-jdbc.conn/connection-details->spec :databricks-sql |
21 | | - [_ {:keys [host http-path token db]}] |
22 | | - {:classname "com.databricks.client.jdbc.Driver" |
23 | | - :subprotocol "databricks" |
24 | | - :subname (str "//" host ":443/" db) |
25 | | - :transportMode "http" |
26 | | - :ssl 1 |
27 | | - :AuthMech 3 |
28 | | - :httpPath http-path |
29 | | - :uid "token" |
30 | | - :pwd token}) |
| 34 | + [_ details] |
| 35 | + (-> details |
| 36 | + (assoc :jdbc-flags (str ";transportMode=http" |
| 37 | + ";ssl=1" |
| 38 | + ";AuthMech=3" |
| 39 | + ";LogLevel=0" |
| 40 | + ";UID=token" |
| 41 | + ";PWD=" (:token details) |
| 42 | + ";httpPath=" (:http-path details))) |
| 43 | + (select-keys [:host :db :jdbc-flags :dbname]) |
| 44 | + sparksql-databricks |
| 45 | + (sql-jdbc.common/handle-additional-options details))) |
31 | 46 |
|
32 | 47 | ;; The Hive JDBC driver doesn't support `Connection.isValid()`, |
33 | 48 | ;; so we need to supply a test query for c3p0 to use to validate |
|
0 commit comments