Skip to content

Commit dee1d7a

Browse files
Merge pull request #2 from db-caioishizaka/catalog_support
Catalog support
2 parents 9a9df2b + bcd99e4 commit dee1d7a

File tree

13 files changed

+349
-28
lines changed

13 files changed

+349
-28
lines changed

.DS_Store

6 KB
Binary file not shown.

.devcontainer/devcontainer.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "clojure",
3+
"build": {
4+
"dockerfile": "../Dockerfile"
5+
},
6+
"forwardPorts": [
7+
3000
8+
],
9+
"workspaceFolder": "/driver",
10+
"mounts": [
11+
{
12+
"source": "${localWorkspaceFolder}",
13+
"target": "${containerWorkspaceFolder}",
14+
"type": "bind"
15+
}
16+
],
17+
"customizations": {
18+
"vscode": {
19+
"extensions": [
20+
"betterthantomorrow.calva"
21+
]
22+
}
23+
}
24+
}

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM clojure:tools-deps-1.11.1.1413
2+
3+
COPY . /driver
4+
5+
RUN apt-get update && apt-get install -y \
6+
curl
7+
8+
ARG METABASE_VERSION="v0.49.3"
9+
10+
RUN curl -Lo - https://github.com/metabase/metabase/archive/refs/tags/${METABASE_VERSION}.tar.gz | tar -xz && mv metabase-* /metabase
11+
12+
WORKDIR /driver

Makefile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11

22
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
3+
METABASE_VERSION=v0.49.3
34

45
build:
56
@echo "build"
6-
clj -X:build :project-dir "\"$(ROOT_DIR)\""
7-
mkdir -p ./plugins
8-
cp ./target/databricks-sql.metabase-driver.jar ./plugins
7+
docker build . -t build-driver
8+
docker run -it \
9+
--mount type=bind,source=$(ROOT_DIR),destination=/driver \
10+
build-driver:latest bash ./bin/build.sh
911

1012
cleanup:
1113
@echo "cleanup"
@@ -16,7 +18,7 @@ cleanup:
1618
run: cleanup
1719
@echo "deploy metabase with databricks-sql driver"
1820
chmod 777 ./plugins
19-
docker run -d -p 3000:3000 \
21+
docker run -it -p 3000:3000 \
2022
--mount type=bind,source=$(ROOT_DIR)/plugins,destination=/plugins \
21-
--mount source=metabase,destination=/metabase.db \
22-
--name metabase metabase/metabase
23+
--mount source=metabase_data,destination=/metabase.db \
24+
--name metabase metabase/metabase:$(METABASE_VERSION)

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,15 @@ make build
1616
## Run Locally
1717

1818
```
19-
docker pull metabase/metabase:latest
20-
2119
make run
2220
```
2321
Once the Metabase startup completes, you can access your Metabase at `localhost:3000`.
2422

2523
## Usage
2624

27-
Copy `host`, `http-path` and your `personal-access-token` to metabase form.
25+
Copy `host`, `http-path`, `personal-access-token`, `Catalog` and `database` to metabase form.
2826

2927

3028
![](screenshots/databricks-sql.png)
31-
![](screenshots/metabase-form.png)
29+
![](screenshots/metabase-form-2.png)
3230

bin/build.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# get absolute path to the driver project directory
4+
DRIVER_PATH="$(pwd)"
5+
6+
# switch to the local checkout of the Metabase repo
7+
cd /metabase
8+
9+
# Build driver. See explanation below
10+
clojure \
11+
-Sdeps "{:aliases {:databricks-sql {:extra-deps {com.metabase/databricks-sql-driver {:local/root \"$DRIVER_PATH\"}}}}}" \
12+
-X:build:databricks-sql \
13+
build-drivers.build-driver/build-driver! \
14+
"{:driver :databricks-sql, :project-dir \"$DRIVER_PATH\", :target-dir \"$DRIVER_PATH/target\"}"
15+
16+
mkdir -p $DRIVER_PATH/plugins
17+
18+
cp $DRIVER_PATH/target/databricks-sql.metabase-driver.jar $DRIVER_PATH/plugins

bin/cli.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
#cp ./bin/deps.edn ~/.clojure/deps.edn
3+
cd ../metabase
4+
5+
function nrepl() {
6+
clojure -M:user/databricks-sql:nrepl
7+
}
8+
9+
function repl() {
10+
clojure -M:user/databricks-sql
11+
}
12+
13+
function options() {
14+
echo "Menu Options:"
15+
echo "[1] nrepl - start an nREPL"
16+
echo "[2] repl - start regular repl"
17+
echo "[3] exit - exit the script"
18+
}
19+
20+
# Main loop
21+
while true; do
22+
options
23+
read -p "Enter your choice (1/2/3): " choice
24+
25+
case $choice in
26+
1)
27+
nrepl
28+
;;
29+
2)
30+
repl
31+
;;
32+
*)
33+
echo "Exiting the script."
34+
cd /driver
35+
exit 0
36+
;;
37+
esac
38+
done

bin/deps.edn

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
;; ~/.clojure/deps.edn
2+
{:aliases
3+
{:user/databricks-sql
4+
{:extra-deps {metabase/databricks-sql {:local/root "/driver"}}
5+
:jvm-opts ["-Dmb.dev.additional.driver.manifest.paths=/driver/resources/metabase-plugin.yaml"]}}}

deps.edn

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
["src" "resources"]
33

44
:deps
5-
{com.databricks/databricks-jdbc {:mvn/version "2.6.27"}}
5+
{com.databricks/databricks-jdbc {:mvn/version "2.6.36" :exclusion [log4j/log4j]}}
6+
7+
;; the stuff below is only for hacking on the driver locally and is not needed if you follow the instructions in the
8+
;; README and create a `:local/root` dep for the driver and launch the REPL from the Metabase project rather than
9+
;; from here
10+
11+
;;; needed for Metabase as a local dep for local development
12+
:mvn/repos
13+
{"opensaml" {:url "https://build.shibboleth.net/nexus/content/repositories/releases/"}}
614

7-
;; build the driver with clojure -X:build
815
:aliases
9-
{:build
10-
{:extra-deps {metabase/metabase-core {:local/root "../metabase"}
11-
metabase/build-drivers {:local/root "../metabase/bin/build-drivers"}}
12-
:exec-fn build-drivers.build-driver/build-driver!
13-
:exec-args {:driver :databricks-sql
14-
:project-dir "."
15-
:target-dir "./target"}}}}
16+
{:dev
17+
{:extra-deps
18+
{io.github.metabase/metabase {:git/tag "v0.49.3", :git/sha "dba0992"}}}}}

resources/metabase-plugin.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,21 @@ driver:
1414
- name: http-path
1515
display-name: HTTP path
1616
required: true
17-
- name: token
17+
- name: password
1818
display-name: Personal Access Token
1919
required: true
2020
- name: db
21-
display-name: Database
21+
display-name: Catalog
22+
default: hive_metastore
23+
required: true
24+
- name: schema
25+
display-name: Database
2226
default: default
23-
required: true
27+
required: true
28+
- advanced-options-start
29+
- default-advanced-options
2430
init:
2531
- step: load-namespace
2632
namespace: metabase.driver.databricks-sql
2733
- step: register-jdbc-driver
28-
class: com.databricks.client.jdbc.Driver
34+
class: com.databricks.client.jdbc.Driver

0 commit comments

Comments
 (0)