The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Support database routing on Oracle (#85095)
dpsutton3ff852d24b7b
diff --git a/.github/workflows/drivers-stress-test.yml b/.github/workflows/drivers-stress-test.ymlindex 4fd41af3f69..6fd67edb59e 100644--- a/.github/workflows/drivers-stress-test.yml+++ b/.github/workflows/drivers-stress-test.yml@@ -430,11 +430,14 @@ jobs:MB_ORACLE_TEST_USER: systemMB_ORACLE_TEST_PASSWORD: passwordMB_ORACLE_TEST_SERVICE_NAME: XEPDB1+ # second PDB (created by ORACLE_DATABASE below) for the database routing tests+ MB_ORACLE_TEST_SERVICE_NAME_ROUTING: MBROUTEservices:oracle:image: gvenzl/oracle-xe:18.4.0-slimenv:ORACLE_PASSWORD: password+ ORACLE_DATABASE: MBROUTEports:- "1521:1521"steps:@@ -456,6 +459,8 @@ jobs:MB_ORACLE_TEST_HOST: localhostMB_ORACLE_TEST_PORT: 2484MB_ORACLE_TEST_SERVICE_NAME: XEPDB1+ # second PDB (created by ORACLE_DATABASE below) for the database routing tests+ MB_ORACLE_TEST_SERVICE_NAME_ROUTING: MBROUTEMB_ORACLE_TEST_SSL: trueMB_ORACLE_TEST_SSL_USE_TRUSTSTORE: trueMB_ORACLE_TEST_SSL_TRUSTSTORE_PATH: './test_resources/ssl/oracle/truststore.p12'@@ -471,6 +476,7 @@ jobs:image: metabase/qa-databases:oracle-xe-21.3env:ORACLE_PASSWORD: password+ ORACLE_DATABASE: MBROUTEports:- "2484:2484"steps:diff --git a/.github/workflows/drivers.yml b/.github/workflows/drivers.ymlindex c7e4cdde918..49949ec82fb 100644--- a/.github/workflows/drivers.yml+++ b/.github/workflows/drivers.yml@@ -685,6 +685,8 @@ jobs:MB_ORACLE_TEST_HOST: localhostMB_ORACLE_TEST_USER: '${{ matrix.version.env.user }}'MB_ORACLE_TEST_SERVICE_NAME: XEPDB1+ # second PDB (created by ORACLE_DATABASE below) for the database routing tests+ MB_ORACLE_TEST_SERVICE_NAME_ROUTING: MBROUTE# Only the non-SSL 18.4 tests specify password as an env var; the SSL 21.3 tests get it from the keystore I guessMB_ORACLE_TEST_PASSWORD: '${{ matrix.version.env.password }}'# These are ignored for the 18.4 tests which do not test SSL@@ -703,6 +705,7 @@ jobs:image: ${{ matrix.version.image }}env:ORACLE_PASSWORD: password+ ORACLE_DATABASE: MBROUTEports:- "1521:${{ matrix.version.port }}"name: ${{ matrix.version.name }}diff --git a/enterprise/backend/test/metabase_enterprise/database_routing/e2e_test.clj b/enterprise/backend/test/metabase_enterprise/database_routing/e2e_test.cljindex 5b18116159b..9a5c449f78a 100644--- a/enterprise/backend/test/metabase_enterprise/database_routing/e2e_test.clj+++ b/enterprise/backend/test/metabase_enterprise/database_routing/e2e_test.clj@@ -343,7 +343,7 @@(defmethod router-dataset-name :default [_driver] "db-router-data")-(doseq [driver [:redshift :databricks :presto-jdbc :bigquery-cloud-sdk]]+(doseq [driver [:redshift :databricks :presto-jdbc :bigquery-cloud-sdk :oracle]](defmethod router-dataset-name driver [_driver] "db-routing-data"))(defmulti routed-dataset-name@@ -354,7 +354,7 @@(defmethod routed-dataset-name :default [_driver] "db-routed-data")-(doseq [driver [:redshift :databricks :presto-jdbc :bigquery-cloud-sdk]]+(doseq [driver [:redshift :databricks :presto-jdbc :bigquery-cloud-sdk :oracle]](defmethod routed-dataset-name driver [_driver] "db-routing-data"))(defmulti router-dataset-detailsdiff --git a/mage/src/mage/start_db.clj b/mage/src/mage/start_db.cljindex ebd364c9c1c..7b731e36a78 100644--- a/mage/src/mage/start_db.clj+++ b/mage/src/mage/start_db.clj@@ -152,6 +152,8 @@["docker" "run" "-d""-p" (str "127.0.0.1:" port ":1521")"-e" "ORACLE_PASSWORD=password"+ ;; second PDB for the database routing tests (MB_ORACLE_TEST_SERVICE_NAME_ROUTING)+ "-e" "ORACLE_DATABASE=MBROUTE""--name" container-name(if (= resolved-version "latest")"gvenzl/oracle-free:latest"diff --git a/modules/drivers/oracle/src/metabase/driver/oracle.clj b/modules/drivers/oracle/src/metabase/driver/oracle.cljindex e9bc2ebc45e..68e4173c6a2 100644--- a/modules/drivers/oracle/src/metabase/driver/oracle.clj+++ b/modules/drivers/oracle/src/metabase/driver/oracle.clj@@ -76,7 +76,7 @@"oracle.net.ssl_server_dn_match" "oracle.net.wallet_location" "server"])(doseq [[feature supported?] {:convert-timezone true- :database-routing false+ :database-routing true:datetime-diff true:describe-default-expr true:describe-is-generated truediff --git a/modules/drivers/oracle/test/metabase/test/data/oracle.clj b/modules/drivers/oracle/test/metabase/test/data/oracle.cljindex 41bf0b5bcbe..6b8fda61e5b 100644--- a/modules/drivers/oracle/test/metabase/test/data/oracle.clj+++ b/modules/drivers/oracle/test/metabase/test/data/oracle.clj@@ -71,7 +71,13 @@:schema-filters-patterns session-schema}details* (merge details*(truststore-details)- (keystore-details))]+ (keystore-details))+ ;; database routing needs a second database whose tables have the same owner and names; on Oracle that is a+ ;; second PDB, reached by service name on the same host+ details* (cond-> details*+ tx/*use-routing-details*+ (assoc :sid nil+ :service-name (tx/db-test-env-var-or-throw :oracle :service-name-routing "MBROUTE")))];; if user or password are not set and we cannot possibly be using SSL auth, set the defaults(cond-> details*(and (nil? (:user details*)) (not (:ssl-use-keystore details*)))@@ -269,6 +275,20 @@(drop-user! session-schema)(create-user! session-schema))+(def ^:private routing-session-user+ "[[tx/before-run]] only creates the session user in the main database. The routing database gets its own, once per+ process, the first time a dataset is created there."+ (delay+ (binding [tx/*use-routing-details* true]+ (drop-user! session-schema)+ (create-user! session-schema))))++(defmethod tx/create-db! :oracle+ [driver dbdef & options]+ (when tx/*use-routing-details*+ @routing-session-user)+ (apply (get-method tx/create-db! :sql-jdbc/test-extensions) driver dbdef options))+(defmethod tx/aggregate-column-info :oracle([driver ag-type](merge