Skip to content
Snippets Groups Projects
Unverified Commit 6c4b14d5 authored by Howon Lee's avatar Howon Lee Committed by GitHub
Browse files

Add option to turn JSON column unfolding off (boat161) (#22997)

Adds option to turn JSON column unfolding off. This does not constitute an actual fix of boat161 but flamber wanted it
parent 174afe58
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@
(driver/register! :postgres, :parent :sql-jdbc)
(defmethod driver/database-supports? [:postgres :nested-field-columns] [_ _ _] true)
(defmethod driver/database-supports? [:postgres :nested-field-columns] [_ _ database] (get-in database [:details :json-unfolding]))
;;; +----------------------------------------------------------------------------------------------------------------+
;;; | metabase.driver impls |
......@@ -161,6 +161,12 @@
:visible-if {"ssl-use-client-auth" true}}
driver.common/ssh-tunnel-preferences
driver.common/advanced-options-start
{:name "json-unfolding"
:display-name (trs "Unfold JSON Columns")
:type :boolean
:visible-if {"advanced-options" true}
:description (trs "We unfold JSON columns into component fields. This is on by default but you can turn it off if performance is slow.")
:default true}
(assoc driver.common/additional-options
:placeholder "prepareThreshold=0")
driver.common/default-advanced-options]
......
......@@ -295,7 +295,8 @@
(mt/test-driver :postgres
(testing "json breakouts and order bys have alias coercion"
(drop-if-exists-and-create-db! "json-alias-test")
(let [details (mt/dbdef->connection-details :postgres :db {:database-name "json-alias-test"})
(let [details (mt/dbdef->connection-details :postgres :db {:database-name "json-alias-test"
:json-unfolding true})
spec (sql-jdbc.conn/connection-details->spec :postgres details)
json-part (json/generate-string {:bob :dobbs})
insert (str "CREATE TABLE json_alias_test (json_part JSON NOT NULL);"
......@@ -325,7 +326,8 @@
(mt/test-driver :postgres
(testing "describes json columns and gives types for ones with coherent schemas only"
(drop-if-exists-and-create-db! "describe-json-test")
(let [details (mt/dbdef->connection-details :postgres :db {:database-name "describe-json-test"})
(let [details (mt/dbdef->connection-details :postgres :db {:database-name "describe-json-test"
:json-unfolding true})
spec (sql-jdbc.conn/connection-details->spec :postgres details)]
(jdbc/with-db-connection [conn (sql-jdbc.conn/connection-details->spec :postgres details)]
(jdbc/execute! spec [(str "CREATE TABLE describe_json_table (coherent_json_val JSON NOT NULL, incoherent_json_val JSON NOT NULL);"
......@@ -383,7 +385,8 @@
(mt/test-driver :postgres
(testing "sync goes and runs with identifier if there is a schema other than default public one"
(drop-if-exists-and-create-db! "describe-json-with-schema-test")
(let [details (mt/dbdef->connection-details :postgres :db {:database-name "describe-json-with-schema-test"})
(let [details (mt/dbdef->connection-details :postgres :db {:database-name "describe-json-with-schema-test"
:json-unfolding true})
spec (sql-jdbc.conn/connection-details->spec :postgres details)]
(jdbc/with-db-connection [conn (sql-jdbc.conn/connection-details->spec :postgres details)]
(jdbc/execute! spec [(str "CREATE SCHEMA bobdobbs;"
......@@ -405,7 +408,8 @@
(mt/test-driver :postgres
(testing "blank out if huge. blank out instead of silently limiting"
(drop-if-exists-and-create-db! "big-json-test")
(let [details (mt/dbdef->connection-details :postgres :db {:database-name "big-json-test"})
(let [details (mt/dbdef->connection-details :postgres :db {:database-name "big-json-test"
:json-unfolding true})
spec (sql-jdbc.conn/connection-details->spec :postgres details)
big-map (into {} (for [x (range 300)] [x :dobbs]))
big-json (json/generate-string big-map)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment