Skip to content

Commit

Permalink
feat: update jdbc version (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
stepansergeevitch authored Jul 23, 2024
1 parent 2df6d73 commit 44815b3
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 128 deletions.
63 changes: 18 additions & 45 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@ name: Run integration tests

on:
workflow_dispatch:
inputs:
database:
description: 'Database - a new one will be created if not provided'
required: false
default: ''
engine:
description: 'Engine - Will be created if database is not provided.'
required: false
default: ''

jobs:
run-integration-tests:
runs-on: ubuntu-latest
Expand All @@ -19,7 +11,7 @@ jobs:
uses: actions/checkout@v2
with:
repository: metabase/metabase
ref: "v0.44.0"
ref: "v0.48.0"

- name: Checkout firebolt connector code
uses: actions/checkout@v2
Expand All @@ -39,6 +31,15 @@ jobs:
cli: '1.11.1.1155' # Clojure CLI based on tools.deps
lein: '2.9.10' # or use 'latest' to always provision latest version of leiningen

- name: Add firebolt driver imports to metabase
shell: bash
run: |
sed --in-place '$ s/..$/\n metabase\/firebolt {:local\/root "firebolt"}}}/' modules/drivers/deps.edn
sed --in-place '/\s:drivers-dev/,+1 {/:extra-paths/,+1 {n;s/^\s*\["/\0modules\/drivers\/firebolt\/test"\n "/ }}' deps.edn
sed --in-place '/\s:check/,+3 {/:main-opts/ {n;s/\("[^"]*"\)/\1\n "modules\/drivers\/firebolt\/src"/}}' deps.edn
export NODE_OPTIONS=--openssl-legacy-provider
yarn build-static-viz
- name: "Build metabase"
shell: bash
run: |
Expand All @@ -47,49 +48,21 @@ jobs:
clojure -X:deps prep
cd ../..
- name: Add firebolt driver imports to metabase
shell: bash
run: |
sed --in-place '2s#$#\n metabase/firebolt {:local/root "firebolt"}#' modules/drivers/deps.edn
sed --in-place '264s#$#\n "modules/drivers/firebolt/test"#' deps.edn
sed --in-place '299s#$#\n "modules/drivers/firebolt/src"#' deps.edn
sed --in-place '$ s/.$//' modules/drivers/deps.edn
sed --in-place '$ a :mvn/repos {"repsy" {:url "https://repo.repsy.io/mvn/firebolt/maven"}}}' modules/drivers/deps.edn
sed --in-place '2s#$#\n :mvn/repos {"repsy" {:url "https://repo.repsy.io/mvn/firebolt/maven"}}#' bin/build-drivers/deps.edn
sed --in-place '2s#$#\n :mvn/repos {"repsy" {:url "https://repo.repsy.io/mvn/firebolt/maven"}}#' bin/build-mb/deps.edn
sed --in-place '2s#$#\n :mvn/repos {"repsy" {:url "https://repo.repsy.io/mvn/firebolt/maven"}}#' bin/release/deps.edn
sed --in-place '152s#$#\n :mvn/repos {"repsy" {:url "https://repo.repsy.io/mvn/firebolt/maven"}}#' deps.edn
export NODE_OPTIONS=--openssl-legacy-provider
yarn build-static-viz
- name: Setup database and engine
id: setup
if: ${{ github.event.inputs.database == '' }}
uses: firebolt-db/integration-testing-setup@v1
with:
firebolt-username: ${{ secrets.FIREBOLT_STG_USERNAME }}
firebolt-password: ${{ secrets.FIREBOLT_STG_PASSWORD }}
api-endpoint: "api.staging.firebolt.io"
region: "us-east-1"

- name: Determine database name
id: find-database-name
run: |
if ! [[ -z "${{ github.event.inputs.database }}" ]]; then
echo "database_name=${{ github.event.inputs.database }}" >> $GITHUB_OUTPUT
else
echo "database_name=${{ steps.setup.outputs.database_name }}" >> $GITHUB_OUTPUT
fi
- name: Determine engine name
id: find-engine-name
run: |
if ! [[ -z "${{ github.event.inputs.database }}" ]]; then
echo "engine_name=${{ github.event.inputs.engine }}" >> $GITHUB_OUTPUT
else
echo "engine_name=${{ steps.setup.outputs.engine_name }}" >> $GITHUB_OUTPUT
fi
- name: Run metabase integration tests
shell: bash
env:
DRIVERS: firebolt
MB_FIREBOLT_TEST_USER: ${{ secrets.FIREBOLT_STG_USERNAME }}
MB_FIREBOLT_TEST_PASSWORD: ${{ secrets.FIREBOLT_STG_PASSWORD }}
MB_FIREBOLT_TEST_DB: ${{ steps.setup.outputs.database_name }}
MB_FIREBOLT_TEST_ADDITIONAL_OPTIONS: engine=${{ steps.setup.outputs.engine_name }}&environment=staging
run: |
DRIVERS=firebolt MB_FIREBOLT_TEST_USER=${{ secrets.SERVICE_ID_STG }} MB_FIREBOLT_TEST_PASSWORD="${{ secrets.SERVICE_SECRET_STG }}" MB_FIREBOLT_TEST_DB=${{ steps.find-database-name.outputs.database_name }} MB_FIREBOLT_TEST_ADDITIONAL_OPTIONS='engine=${{ steps.find-engine-name.outputs.engine_name }}&environment=staging' clojure -X:dev:drivers:drivers-dev:test
clojure -X:dev:drivers:drivers-dev:test
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ You should see a message on startup similar to:

## Compatibility matrix

| Firebolt Version | Metabase Release | Driver Version |
|------------------|------------------|----------------|
| 1 | <=0.47.x | <=1.0.13 |
| 1 | <=0.47.x | <=1.0.13 |
| 2 | <=0.47.x | 3.0.0 |
| 1&2 | <=0.47.x | 3.0.1 |
| 1&2 | 0.48.x | 3.0.3 |
| 1&2 | 0.49.x | 3.0.3 |
| Metabase Release | Driver Version |
|------------------|----------------|
| <=0.47.x | 3.0.1 |
| \>=0.48.x | 3.1.0 |
4 changes: 1 addition & 3 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
["src" "resources"]

:deps
{io.firebolt/firebolt-jdbc {:mvn/version "3.0.3"}}
:mvn/repos
; {"releases" {:url "https://repo.repsy.io/mvn/firebolt/maven"}}
{io.firebolt/firebolt-jdbc {:mvn/version "3.1.0"}}

;; build the driver with clojure -X:build
:aliases
Expand Down
11 changes: 7 additions & 4 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
(defproject metabase/firebolt-driver "3.0.3"
(def version "3.0.4")
(def jdbc-version "3.1.0")

(defproject metabase/firebolt-driver version
:min-lein-version "3.0.0"

:dependencies
[[io.firebolt/firebolt-jdbc "3.0.3"]]
[[io.firebolt/firebolt-jdbc jdbc-version]]

:repositories [["snapshots" {:sign-releases false
:url "https://repo.repsy.io/mvn/firebolt/maven-snapshots"
Expand All @@ -27,8 +30,8 @@
:javac-options ["-target" "1.8", "-source" "1.8"]
:target-path "target/%s"
:manifest {
"Implementation-Title" "Firebolt JDBC driver"
"Implementation-Version" "3.0.3"
"Implementation-Title" "Firebolt Metabase driver"
"Implementation-Version" version
}
:uberjar-name "firebolt.metabase-driver.jar"}})

3 changes: 1 addition & 2 deletions resources/metabase-plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ driver:
placeholder: database name
- name: account
display-name: Account name
required: false
required: true
placeholder: account name
helper-text: If not specified, the default account will be picked.
- name: engine_name
display-name: Engine name
required: false
Expand Down
39 changes: 23 additions & 16 deletions src/metabase/driver/firebolt.clj
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,19 @@

;;; ---------------------------------------------- sql-jdbc.connection -----------------------------------------------

(defn parse-additional-options [query-string]
(let [pairs (clojure.string/split query-string #"&")
kv-pairs (map #(clojure.string/split % #"=") pairs)]
(into {} (map (fn [[k v]] [(keyword k) v]) kv-pairs))))

; Create database specification and obtain connection properties for connecting to a Firebolt database.
(defmethod sql-jdbc.conn/connection-details->spec :firebolt
[_ {:keys [db]
:or {db ""}
:as details}]
(let [spec {:classname "com.firebolt.FireboltDriver", :subprotocol "firebolt", :subname (str "//api." (System/getProperty "env" "app") ".firebolt.io/" db), :ssl true}]
(let [
env (System/getProperty "env" (get (parse-additional-options (get details :additional-options "")) :environment "app"))
spec {:classname "com.firebolt.FireboltDriver", :subprotocol "firebolt", :subname (str "//api." env ".firebolt.io/" db), :ssl true}]
(-> (merge spec (select-keys details [:password :classname :subprotocol :user :subname :additional-options :account :engine_name :env]))
(sql-jdbc.common/handle-additional-options (select-keys details [:password :classname :subprotocol :user :subname :additional-options :account :engine_name :env]))
)))
Expand Down Expand Up @@ -134,22 +141,22 @@
(defmethod sql.qp/add-interval-honeysql-form :firebolt [_ dt amount unit] (h2x/+ dt [:raw (format "INTERVAL %d %s" (int amount) (name unit))]))

; Format a temporal value `t` as a SQL-style literal string, converting time datatype to SQL-style literal string
(defmethod unprepare/unprepare-value [:firebolt LocalTime]
(defmethod unprepare/unprepare [:firebolt LocalTime]
[_ t]
(format "'%s'" t))

; Converting ZonedDateTime datatype to SQL-style literal string
(defmethod unprepare/unprepare-value [:firebolt ZonedDateTime]
(defmethod unprepare/unprepare [:firebolt ZonedDateTime]
[_ t]
(format "timestamp '%s'" (u.date/format-sql (t/local-date-time t))))

; Converting OffsetDateTime datatype to SQL-style literal string
(defmethod unprepare/unprepare-value [:firebolt OffsetDateTime]
(defmethod unprepare/unprepare [:firebolt OffsetDateTime]
[_ t]
(format "timestamp '%s'" (u.date/format-sql (t/local-date-time t))))

; Converting OffsetTime datatype to SQL-style literal string
(defmethod unprepare/unprepare-value [:firebolt OffsetTime]
(defmethod unprepare/unprepare [:firebolt OffsetTime]
[_ t]
(format "timestamp '%s'" (u.date/format-sql (t/local-date-time t))))

Expand Down Expand Up @@ -326,27 +333,27 @@

;-------------------------Supported features---------------------------

(defmethod driver/supports? [:firebolt :basic-aggregations] [_ _] true)
(defmethod driver/database-supports? [:firebolt :basic-aggregations] [_ _] true)

(defmethod driver/supports? [:firebolt :expression-aggregations] [_ _] true)
(defmethod driver/database-supports? [:firebolt :expression-aggregations] [_ _] true)

(defmethod driver/supports? [:firebolt :percentile-aggregations] [_ _] true)
(defmethod driver/database-supports? [:firebolt :percentile-aggregations] [_ _] true)

(defmethod driver/supports? [:firebolt :foreign-keys] [_ _] true)
(defmethod driver/database-supports? [:firebolt :foreign-keys] [_ _] true)

(defmethod driver/supports? [:firebolt :binning] [_ _] true)
(defmethod driver/database-supports? [:firebolt :binning] [_ _] true)

(defmethod driver/supports? [:firebolt :regex] [_ _] true)
(defmethod driver/database-supports? [:firebolt :regex] [_ _] true)

(defmethod driver/supports? [:firebolt :standard-deviation-aggregations] [_ _] false)
(defmethod driver/database-supports? [:firebolt :standard-deviation-aggregations] [_ _] false)

(defmethod driver/supports? [:firebolt :nested-queries] [_ _] false)
(defmethod driver/database-supports? [:firebolt :nested-queries] [_ _] false)

(defmethod driver/supports? [:firebolt :case-sensitivity-string-filter-options] [_ _] false)
(defmethod driver/database-supports? [:firebolt :case-sensitivity-string-filter-options] [_ _] false)

(defmethod driver/supports? [:firebolt :set-timezone] [_ _] false)
(defmethod driver/database-supports? [:firebolt :set-timezone] [_ _] false)

(defmethod driver/supports? [:firebolt :nested-fields] [_ _] false)
(defmethod driver/database-supports? [:firebolt :nested-fields] [_ _] false)



Expand Down
Loading

0 comments on commit 44815b3

Please sign in to comment.