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

Cutoff instead of null out nested field column set if there are too many (#24336)

Pursuant to #23635. Previous behavior was to blank out the nested field columns if there were too many for our arbitrary limit (of 100). However, this silent behavior was very user-unfriendly, and people were perplexed that the feature just seemed to turn off out of nowhere. New, better behavior is to log that there are too many and cut it off at 100, but still have some if there are 100.
parent f867e114
Branches
Tags
No related merge requests found
......@@ -371,5 +371,10 @@
field-types (transduce describe-json-xform describe-json-rf query)
fields (field-types->fields field-types)]
(if (> (count fields) max-nested-field-columns)
#{}
(do
(log/warn
(format
"More nested field columns detected than maximum. Limiting the number of nested field columns to %d."
max-nested-field-columns))
(set (take max-nested-field-columns fields)))
fields))))))
......@@ -436,11 +436,11 @@
(mt/dataset json
(when (not (is-mariadb? (u/id (mt/db))))
(testing "Nested field column listing, but big"
(is (= #{}
(sql-jdbc.sync/describe-nested-field-columns
:mysql
(mt/db)
{:name "big_json"}))))))))
(is (= metabase.driver.sql-jdbc.sync.describe-table/max-nested-field-columns
(count (sql-jdbc.sync/describe-nested-field-columns
:mysql
(mt/db)
{:name "big_json"})))))))))
(deftest json-query-test
(let [boop-identifier (:form (hx/with-type-info (hx/identifier :field "boop" "bleh -> meh") {}))]
......
......@@ -467,7 +467,7 @@
(deftest describe-big-nested-field-columns-test
(mt/test-driver :postgres
(testing "blank out if huge. blank out instead of silently limiting"
(testing "limit if huge. limit it and yell warning (#23635)"
(drop-if-exists-and-create-db! "big-json-test")
(let [details (mt/dbdef->connection-details :postgres :db {:database-name "big-json-test"
:json-unfolding true})
......@@ -479,11 +479,19 @@
(jdbc/with-db-connection [conn (sql-jdbc.conn/connection-details->spec :postgres details)]
(jdbc/execute! spec [sql]))
(mt/with-temp Database [database {:engine :postgres, :details details}]
(is (= #{}
(sql-jdbc.sync/describe-nested-field-columns
:postgres
database
{:name "big_json_table"}))))))))
(is (= metabase.driver.sql-jdbc.sync.describe-table/max-nested-field-columns
(count
(sql-jdbc.sync/describe-nested-field-columns
:postgres
database
{:name "big_json_table"}))))
(is (str/includes?
(get-in (mt/with-log-messages-for-level :warn
(sql-jdbc.sync/describe-nested-field-columns
:postgres
database
{:name "big_json_table"})) [0 2])
"More nested field columns detected than maximum.")))))))
(mt/defdataset with-uuid
[["users"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment