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
Revert "Upgrade clickhouse jdbc driver to 0.9.7" (#70403)
Riley Thompson0a0625d1631e
diff --git a/enterprise/backend/test/metabase_enterprise/impersonation/driver_test.clj b/enterprise/backend/test/metabase_enterprise/impersonation/driver_test.cljindex a51ba0cfd13..cd10ec56aae 100644--- a/enterprise/backend/test/metabase_enterprise/impersonation/driver_test.clj+++ b/enterprise/backend/test/metabase_enterprise/impersonation/driver_test.clj@@ -899,8 +899,38 @@(mt/run-mbql-query venues{:aggregation [[:count]]}))))))))))))))))-(deftest clickhouse-double-hyphen-test- (testing "can use impersonation on clickhouse with role containing a double hyphen (#57016)"+;; TODO(rileythomp, 2026-01-23): Enable this test when we upgrade ClickHouse JDBC driver past 0.8.4+#_(deftest clickhouse-double-hyphen-test+ (testing "can use impersonation on clickhouse with role containing a double hyphen (#57016)"+ (mt/test-driver :clickhouse+ (mt/with-premium-features #{:advanced-permissions}+ (let [venues-table (sql.tx/qualify-and-quote driver/*driver* "test-data" "venues")+ role-a "role--with--double--hyphens"]+ (tx/with-temp-roles! driver/*driver*+ (impersonation-granting-details driver/*driver* (mt/db))+ {role-a {venues-table {}}}+ (impersonation-default-user driver/*driver*)+ (impersonation-default-role driver/*driver*)+ (mt/with-temp [:model/Database database {:engine driver/*driver*,+ :details (impersonation-details driver/*driver* (mt/db))}]+ (mt/with-db database+ (when (driver/database-supports? driver/*driver* :connection-impersonation-requires-role nil)+ (t2/update! :model/Database :id (mt/id) (assoc-in (mt/db) [:details :role] (impersonation-default-role driver/*driver*))))+ (sync/sync-database! database {:scan :schema})+ (impersonation.util-test/with-impersonations! {:impersonations [{:db-id (mt/id) :attribute "impersonation_attr"}]+ :attributes {"impersonation_attr" role-a}}+ (is (= [[100]]+ (mt/formatted-rows [int]+ (mt/run-mbql-query venues+ {:aggregation [[:count]]}))))+ (is (thrown?+ java.lang.Exception+ (mt/run-mbql-query checkins+ {:aggregation [[:count]]}))))))))))))++;; TODO(rileythomp, 2026-01-28): Verify this test can be removed after upgrading ClickHouse JDBC driver past 0.8.4+(deftest clickhouse-double-hyphen-role-doesnt-break-all-queries-test+ (testing "using an unknown role on clickhouse won't break queries for other users (68674)"(mt/test-driver :clickhouse(mt/with-premium-features #{:advanced-permissions}(let [venues-table (sql.tx/qualify-and-quote driver/*driver* "test-data" "venues")@@ -918,11 +948,16 @@(sync/sync-database! database {:scan :schema})(impersonation.util-test/with-impersonations! {:impersonations [{:db-id (mt/id) :attribute "impersonation_attr"}]:attributes {"impersonation_attr" role-a}}- (is (= [[100]]- (mt/formatted-rows [int]- (mt/run-mbql-query venues- {:aggregation [[:count]]}))))- (is (thrown?- java.lang.Exception- (mt/run-mbql-query checkins- {:aggregation [[:count]]}))))))))))))+ (testing "using double hyphen role causes an error"+ (is (thrown?+ java.lang.Exception+ (mt/run-mbql-query venues+ {:aggregation [[:count]]}))))+ (testing "admin should still be able to query"+ (request/as-admin+ (is (= [100]+ (map+ long+ (mt/first-row+ (mt/run-mbql-query venues+ {:aggregation [[:count]]}))))))))))))))))diff --git a/modules/drivers/clickhouse/deps.edn b/modules/drivers/clickhouse/deps.ednindex 76dea0c1592..8d691785528 100644--- a/modules/drivers/clickhouse/deps.edn+++ b/modules/drivers/clickhouse/deps.edn@@ -1,5 +1,5 @@{:paths ["src" "resources"]:deps- {com.clickhouse/clickhouse-jdbc {:mvn/version "0.9.7"+ {com.clickhouse/clickhouse-jdbc {:mvn/version "0.8.4":exclusions [org.apache.commons/commons-lang3]}org.lz4/lz4-java {:mvn/version "1.8.0"}}}diff --git a/modules/drivers/clickhouse/src/metabase/driver/clickhouse.clj b/modules/drivers/clickhouse/src/metabase/driver/clickhouse.cljindex 457b99bb5eb..1203d1b87bc 100644--- a/modules/drivers/clickhouse/src/metabase/driver/clickhouse.clj+++ b/modules/drivers/clickhouse/src/metabase/driver/clickhouse.clj@@ -123,11 +123,10 @@:http_connection_provider "HTTP_URL_CONNECTION":jdbc_ignore_unsupported_values "true":jdbc_schema_term "schema"+ :select_sequential_consistency true:max_open_connections (or max-open-connections 100);; see also: https://clickhouse.com/docs/en/integrations/java#configuration- :custom_http_params (cond-> "select_sequential_consistency=1"- (not (str/blank? clickhouse-settings))- (str "," clickhouse-settings))}+ :custom_http_params (or clickhouse-settings "")}(sql-jdbc.common/handle-additional-options details :separator-style :url))))(defmethod driver/database-supports? [:clickhouse :uploads] [_driver _feature db]@@ -407,5 +406,13 @@(.addBatch ^Statement stmt ^String sql))(.executeBatch ^Statement stmt)))))+(defmethod sql-jdbc.conn/data-warehouse-connection-pool-properties :clickhouse+ [driver database]+ (merge+ ((get-method sql-jdbc.conn/data-warehouse-connection-pool-properties :sql-jdbc) driver database)+ ;; TODO(rileythomp, 2026-01-29): Remove this once we upgrade past 0.8.4+ ;; This is to work around 68674 where connections are being poisoned with bad roles+ {"preferredTestQuery" "SELECT 1"}))+(defmethod driver/llm-sql-dialect-resource :clickhouse [_]"llm/prompts/dialects/clickhouse.md")diff --git a/modules/drivers/clickhouse/test/metabase/driver/clickhouse_data_types_test.clj b/modules/drivers/clickhouse/test/metabase/driver/clickhouse_data_types_test.cljindex 77632a486c5..db560c6ff1c 100644--- a/modules/drivers/clickhouse/test/metabase/driver/clickhouse_data_types_test.clj+++ b/modules/drivers/clickhouse/test/metabase/driver/clickhouse_data_types_test.clj@@ -441,19 +441,19 @@[{:field-name "mystring" :base-type :type/Text}][["foo"] ["bar"] [" "] [""] [nil]]]])(testing "null strings count"- (is (= 2+ (is (= 2M(-> (mt/run-mbql-query test-data-nullable-strings{:filter [:is-null $mystring]:aggregation [:count]})mt/first-row last))))(testing "nullable strings not null filter"- (is (= 3+ (is (= 3M(-> (mt/run-mbql-query test-data-nullable-strings{:filter [:not-null $mystring]:aggregation [:count]})mt/first-row last))))(testing "filter nullable string by value"- (is (= 1+ (is (= 1M(-> (mt/run-mbql-query test-data-nullable-strings{:filter [:= $mystring "foo"]:aggregation [:count]})diff --git a/modules/drivers/clickhouse/test/metabase/driver/clickhouse_test.clj b/modules/drivers/clickhouse/test/metabase/driver/clickhouse_test.cljindex ebdb4b79466..fab194d7d1f 100644--- a/modules/drivers/clickhouse/test/metabase/driver/clickhouse_test.clj+++ b/modules/drivers/clickhouse/test/metabase/driver/clickhouse_test.clj@@ -61,7 +61,7 @@:user "bob":password "qaz":ssl true- :custom_http_params "select_sequential_consistency=1,max_threads=42,allow_experimental_analyzer=0"})+ :custom_http_params "max_threads=42,allow_experimental_analyzer=0"})(sql-jdbc.conn/connection-details->spec:clickhouse{:host "myclickhouse"@@ -100,7 +100,7 @@(deftest ^:parallel clickhouse-connection-string-select-sequential-consistency(testing "connection with no additional options"- (is (= ctd/default-connection-params+ (is (= (assoc ctd/default-connection-params :select_sequential_consistency true)(sql-jdbc.conn/connection-details->spec:clickhouse{})))))@@ -255,32 +255,34 @@:target [:dimension [:template-tag "category_name"]]:value ["African"]}]}))))))))-(deftest ^:parallel ternary-with-variable-test- (mt/test-driver :clickhouse- (testing "a query with a ternary and a variable should work correctly (#56690)"- (is (= [[1 "African" 1]]- (mt/rows- (qp/process-query- {:database (mt/id)- :type :native- :native {:query "SELECT *, true ? 1 : 0 AS foo+;; TODO(rileythomp, 2026-01-21): Re-enable this test when the ClickHouse JDBC driver is upgraded+#_(deftest ^:parallel ternary-with-variable-test+ (mt/test-driver :clickhouse+ (testing "a query with a ternary and a variable should work correctly (#56690)"+ (is (= [[1 "African" 1]]+ (mt/rows+ (qp/process-query+ {:database (mt/id)+ :type :native+ :native {:query "SELECT *, true ? 1 : 0 AS fooFROM test_data.categoriesWHERE name = {{category_name}};"- :template-tags {"category_name" {:type :text- :name "category_name"- :display-name "Category Name"}}}- :parameters [{:type :category- :target [:variable [:template-tag "category_name"]]- :value "African"}]})))))))+ :template-tags {"category_name" {:type :text+ :name "category_name"+ :display-name "Category Name"}}}+ :parameters [{:type :category+ :target [:variable [:template-tag "category_name"]]+ :value "African"}]})))))))-(deftest ^:parallel line-comment-block-comment-test- (mt/test-driver :clickhouse- (testing "a query with a line comment followed by a block comment should work correctly (#57149, #62741)"- (is (= [[1]]- (mt/rows- (qp/process-query- (mt/native-query- {:query "-- foo+;; TODO(rileythomp, 2026-01-21): Re-enable this test when the ClickHouse JDBC driver is upgraded+#_(deftest ^:parallel line-comment-block-comment-test+ (mt/test-driver :clickhouse+ (testing "a query with a line comment followed by a block comment should work correctly (#57149, #62741)"+ (is (= [[1]]+ (mt/rows+ (qp/process-query+ (mt/native-query+ {:query "-- foo/* comment */select 1;"}))))))))diff --git a/modules/drivers/clickhouse/test/metabase/test/data/clickhouse.clj b/modules/drivers/clickhouse/test/metabase/test/data/clickhouse.cljindex f01634906c5..5c19261a622 100644--- a/modules/drivers/clickhouse/test/metabase/test/data/clickhouse.clj+++ b/modules/drivers/clickhouse/test/metabase/test/data/clickhouse.clj@@ -56,7 +56,8 @@:max_open_connections 100:remember_last_set_roles true:http_connection_provider "HTTP_URL_CONNECTION"- :custom_http_params "select_sequential_consistency=1"})+ :custom_http_params ""+ :select_sequential_consistency true})(defmethod sql.tx/field-base-type->sql-type [:clickhouse :type/Boolean] [_ _] "Boolean")(defmethod sql.tx/field-base-type->sql-type [:clickhouse :type/BigInteger] [_ _] "Int64")