Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Commit 3c43183

Browse files
authored
Merge pull request #5 from buserbrasil/add_devcontainer
add devcontainer and make possible to build v0.47.3
2 parents e8fa9ab + 2517f44 commit 3c43183

File tree

12 files changed

+193
-93
lines changed

12 files changed

+193
-93
lines changed

.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+
}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ pom.xml.asc
1212
.hg/
1313
.lsp
1414
.clj-kondo
15+
.calva
1516
/plugins
1617
.cpcache
1718

1819
# vscode
1920
.vscode
20-
.idea
21+
.idea
22+
*.iml

Dockerfile

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

Makefile

Lines changed: 8 additions & 10 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.47.3
34

45
build:
56
@echo "build"
6-
./bin/build.sh
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,11 +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-
24-
first-run:
25-
docker pull metabase/metabase:latest
26-
make run
23+
--mount source=metabase_data,destination=/metabase.db \
24+
--name metabase metabase/metabase:$(METABASE_VERSION)

README.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,24 @@
44

55
Beginning with Metabase 0.32, drivers must be stored in a `plugins` directory in the same directory where `metabase.jar` is, or you can specify the directory by setting the environment variable `MB_PLUGINS_DIR`. There are a few options to get up and running with a custom driver.
66

7-
You can find jar file on the [release page](https://github.com/schumannc/databricks-sql-driver/releases) or you can build it locally.
7+
You can find jar file on the [release page](https://github.com/buserbrasil/databricks-sql-driver/releases) or you can build it locally.
88
## Build
99

10-
In order to build it locally, you're gonna need [metabase](https://github.com/metabase/metabase) project to build this project, so make sure you clone it in a parent directory.
10+
Run the following command to build plugin jar file:
1111

1212
```
1313
make build
1414
```
1515

16+
If all succeed you will find the driver jar under ./plugins folder.
17+
18+
1619
## Run Locally
1720

1821
```
19-
make first-run
22+
make run
2023
```
21-
Once the Metabase startup completes, you can access your Metabase at `localhost:3000`, which pulls metabase docker image and then start this project. Next time you need to run this project again, you can use `make run` command.
24+
Once the Metabase startup completes, you can access your Metabase at `localhost:3000`, which pulls metabase docker image and then start this project.
2225

2326
## Add Data
2427

@@ -31,3 +34,18 @@ When you first access, fill some basic info and then go to "Add your data" secti
3134
![](screenshots/databricks-sql.png)
3235
![](screenshots/metabase-form.png)
3336

37+
## Hacking the Driver whtin devcontainer
38+
39+
For further development try to use devcontainer setup.
40+
41+
To start a (n)REPL:
42+
43+
```
44+
./bin/cli.sh
45+
46+
Menu Options:
47+
[1] nrepl - start an nREPL
48+
[2] repl - start regular repl
49+
[3] exit - exit the script
50+
Enter your choice (1/2/3):
51+
```

bin/build.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
DRIVER_PATH="$(pwd)"
55

66
# switch to the local checkout of the Metabase repo
7-
cd ../metabase
7+
cd /metabase
88

99
# Build driver. See explanation below
1010
clojure \
1111
-Sdeps "{:aliases {:databricks-sql {:extra-deps {com.metabase/databricks-sql-driver {:local/root \"$DRIVER_PATH\"}}}}}" \
1212
-X:build:databricks-sql \
1313
build-drivers.build-driver/build-driver! \
14-
"{:driver :databricks-sql, :project-dir \"$DRIVER_PATH\", :target-dir \"$DRIVER_PATH/target\"}"
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 /driver/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"]}}}

databricks-sql-driver.iml

Lines changed: 0 additions & 13 deletions
This file was deleted.

deps.edn

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
["src" "resources"]
33

44
:deps
5-
{org.clojure/core.logic {:mvn/version "1.0.0"}
6-
com.databricks/databricks-jdbc {:mvn/version "2.6.32"}}
5+
{org.clojure.clr/core.logic {:mvn/version "1.0.1"}
6+
com.databricks/databricks-jdbc {:mvn/version "2.6.34"}}
77

88
;; the stuff below is only for hacking on the driver locally and is not needed if you follow the instructions in the
99
;; README and create a `:local/root` dep for the driver and launch the REPL from the Metabase project rather than
@@ -16,4 +16,4 @@
1616
:aliases
1717
{:dev
1818
{:extra-deps
19-
{io.github.metabase/metabase {:git/tag "v0.46.0-RC2", :git/sha "32977a42"}}}}}
19+
{io.github.metabase/metabase {:git/tag "v0.47.3", :git/sha "4202328"}}}}}

0 commit comments

Comments
 (0)