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
implement driver.sql/json-field-length for druid-jdbc driver (#66525)
Riley Thompsonc4cabddf8e37
diff --git a/modules/drivers/druid-jdbc/src/metabase/driver/druid_jdbc.clj b/modules/drivers/druid-jdbc/src/metabase/driver/druid_jdbc.cljindex 215c1e753cb..ad8b346ec8b 100644--- a/modules/drivers/druid-jdbc/src/metabase/driver/druid_jdbc.clj+++ b/modules/drivers/druid-jdbc/src/metabase/driver/druid_jdbc.clj@@ -7,6 +7,7 @@[metabase.driver :as driver][metabase.driver-api.core :as driver-api][metabase.driver.common :as driver.common]+ [metabase.driver.sql :as driver.sql][metabase.driver.sql-jdbc.connection :as sql-jdbc.conn][metabase.driver.sql-jdbc.execute :as sql-jdbc.execute][metabase.driver.sql-jdbc.sync :as sql-jdbc.sync]@@ -154,6 +155,10 @@::json_value)][operator parent-identifier (h2x/literal (str/join "." (cons "$" (rest nfc-path))))]))+(defmethod driver.sql/json-field-length :druid-jdbc+ [_driver json-field-identifier]+ [:length [:to_json_string json-field-identifier]])+(defmethod sql.qp/->honeysql [:druid-jdbc :field][driver [_ id-or-name opts :as clause]](let [stored-field (when (integer? id-or-name)diff --git a/modules/drivers/druid-jdbc/test/metabase/driver/druid_jdbc_test.clj b/modules/drivers/druid-jdbc/test/metabase/driver/druid_jdbc_test.cljindex 9b1b469e390..91662c2edf9 100644--- a/modules/drivers/druid-jdbc/test/metabase/driver/druid_jdbc_test.clj+++ b/modules/drivers/druid-jdbc/test/metabase/driver/druid_jdbc_test.clj@@ -5,6 +5,8 @@[malli.error :as me][metabase.driver :as driver][metabase.driver.common.table-rows-sample :as table-rows-sample]+ [metabase.driver.settings :as driver.settings]+ [metabase.driver.sql-jdbc.sync.interface :as sql-jdbc.sync.interface][metabase.driver.util :as driver.u][metabase.query-processor :as qp][metabase.query-processor.compile :as qp.compile]@@ -134,6 +136,80 @@(catch Throwable t[::failure t]))))))))+(deftest ^:synchronized new-sync-test+ (mt/test-driver+ :druid-jdbc+ (tqpt/with-flattened-dbdef+ (mt/with-temporary-setting-values [driver.settings/nested-field-columns-value-length-limit 10]+ (testing "nested fields when length limit is exceeded"+ (is (= #{}+ (sql-jdbc.sync.interface/describe-nested-field-columns driver/*driver* (mt/db) (t2/select-one :model/Table (mt/id :json)))))))+ (testing "nested fields when length limit is exceeded"+ (is (= #{{:name "json_bit → noop",+ :database-type "timestamp",+ :base-type :type/DateTime,+ :database-position 0,+ :json-unfolding false,+ :visibility-type :normal,+ :nfc-path [:json_bit "noop"]}+ {:name "json_bit → genres",+ :database-type "text",+ :base-type :type/Array,+ :database-position 0,+ :json-unfolding false,+ :visibility-type :normal,+ :nfc-path [:json_bit "genres"]}+ {:name "json_bit → 1234",+ :database-type "decimal",+ :base-type :type/Integer,+ :database-position 0,+ :json-unfolding false,+ :visibility-type :normal,+ :nfc-path [:json_bit "1234"]}+ {:name "json_bit → doop",+ :database-type "text",+ :base-type :type/Text,+ :database-position 0,+ :json-unfolding false,+ :visibility-type :normal,+ :nfc-path [:json_bit "doop"]}+ {:name "json_bit → published",+ :database-type "text",+ :base-type :type/Text,+ :database-position 0,+ :json-unfolding false,+ :visibility-type :normal,+ :nfc-path [:json_bit "published"]}+ {:name "json_bit → boop",+ :database-type "timestamp",+ :base-type :type/DateTime,+ :database-position 0,+ :json-unfolding false,+ :visibility-type :normal,+ :nfc-path [:json_bit "boop"]}+ {:name "json_bit → zoop",+ :database-type "timestamp",+ :base-type :type/DateTime,+ :database-position 0,+ :json-unfolding false,+ :visibility-type :normal,+ :nfc-path [:json_bit "zoop"]}+ {:name "json_bit → 1234123412314",+ :database-type "timestamp",+ :base-type :type/DateTime,+ :database-position 0,+ :json-unfolding false,+ :visibility-type :normal,+ :nfc-path [:json_bit "1234123412314"]}+ {:name "json_bit → title",+ :database-type "text",+ :base-type :type/Text,+ :database-position 0,+ :json-unfolding false,+ :visibility-type :normal,+ :nfc-path [:json_bit "title"]}}+ (sql-jdbc.sync.interface/describe-nested-field-columns driver/*driver* (mt/db) (t2/select-one :model/Table (mt/id :json)))))))))+(defn- db-dbms-version [db-or-id](t2/select-one-fn :dbms_version :model/Database :id (u/the-id db-or-id)))