Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Test to confirm #63261 is fixed in `master` (#63414)

Cam Saul40420f8d440b
diff --git a/test/metabase/query_processor/pivot_test.clj b/test/metabase/query_processor/pivot_test.clj
index 4ddc5330c39..556b825f28e 100644
--- a/test/metabase/query_processor/pivot_test.clj
+++ b/test/metabase/query_processor/pivot_test.clj
@@ -10,6 +10,7 @@
[metabase.lib.metadata :as lib.metadata]
[metabase.lib.test-metadata :as meta]
[metabase.lib.test-util :as lib.tu]
+ [metabase.lib.test-util.notebook-helpers :as lib.tu.notebook]
[metabase.permissions.models.data-permissions :as data-perms]
[metabase.permissions.models.permissions-group :as perms-group]
[metabase.query-processor :as qp]
@@ -19,6 +20,7 @@
[metabase.test :as mt]
[metabase.test.data :as data]
[metabase.util :as u]
+ [metabase.util.malli :as mu]
[metabase.util.malli.registry :as mr]))
(set! *warn-on-reflection* true)
@@ -762,3 +764,39 @@
(is (= {:pivot-rows [0 1], :pivot-cols nil, :pivot-measures [2],
:show-row-totals true, :show-column-totals true}
(#'qp.pivot/column-name-pivot-options query viz-settings))))))
+
+(deftest ^:parallel horrible-pivot-test
+ (testing "#63261"
+ ;; this pivot is so horrible, it takes like 12 seconds to preprocess with all the Malli schema checks. We don't have
+ ;; all day, just disable the checks for this one test.
+ (mu/disable-enforcement
+ (let [mp (-> (mt/metadata-provider)
+ (as-> $mp (lib.tu/mock-metadata-provider
+ $mp
+ {:cards [{:id 1
+ :name "Q1: Orders + People"
+ :dataset-query (-> (lib/query $mp (lib.metadata/table $mp (mt/id :orders)))
+ (lib/join (lib.metadata/table $mp (mt/id :people)))
+ (lib/order-by (lib.metadata/field $mp (mt/id :orders :id)))
+ (lib/limit 3))}]}))
+ (as-> $mp (lib.tu/mock-metadata-provider
+ $mp
+ (let [query (-> (lib/query $mp (lib.metadata/table $mp (mt/id :products)))
+ (lib/join (lib.metadata/card $mp 1))
+ (lib/limit 3))]
+ {:cards [{:id 2
+ :name "Nested: Products + Q1: Orders + People"
+ :dataset-query query}]}))))
+ query (-> (lib/query mp (lib.metadata/card mp 2))
+ (lib/aggregate (lib/count))
+ (as-> $query (lib/breakout $query (lib.tu.notebook/find-col-with-spec
+ $query
+ (lib/breakoutable-columns $query)
+ {:display-name "Nested: Products + Q1: Orders + People"}
+ ;; not sure this is the right column?
+ {:display-name "Q1: Orders + People → Name"})))
+ (lib/limit 3))]
+ (is (= [[nil 0 3]
+ [nil 1 3]]
+ (mt/rows
+ (qp.pivot/run-pivot-query query))))))))