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
Fix conversion of pivot value keys to consistent types (#62762)
Noah Mossde01ff004efb
diff --git a/src/metabase/pivot/core.cljc b/src/metabase/pivot/core.cljcindex 3851e5dd2d6..98279fcaf12 100644--- a/src/metabase/pivot/core.cljc+++ b/src/metabase/pivot/core.cljc@@ -194,7 +194,7 @@(let [col-and-row-indexes (into (vec col-indexes) row-indexes)](reduce(fn [acc row]- (let [value-key (ensure-consistent-type (select-indexes row col-and-row-indexes))+ (let [value-key (perf/mapv ensure-consistent-type (select-indexes row col-and-row-indexes))values (select-indexes row val-indexes)data (into [](map-indexeddiff --git a/test/metabase/api/downloads_exports_test.clj b/test/metabase/api/downloads_exports_test.cljindex ebaa5711670..06f91e1ecdd 100644--- a/test/metabase/api/downloads_exports_test.clj+++ b/test/metabase/api/downloads_exports_test.clj@@ -1712,3 +1712,26 @@(let [result (card-download card {:export-format :csv :format-rows true :pivot true})](is (= expected (take (count expected) result))(str "Failed for condense_duplicate_totals=" condense?)))))))))++(deftest ^:parallel pivot-bigint-bigdecimal-normalization-test+ (testing "Ensure key normalization for values-by-key handles BigInts and BigDecimals properly (#62724)"+ (mt/dataset test-data+ (mt/with-temp [:model/Card card+ {:display :pivot+ :visualization_settings {:pivot_table.column_split+ {:rows ["ID"]+ :columns ["RATING"]+ :values ["avg"]}}+ :dataset_query (mt/mbql-query products+ {:aggregation [[:avg $price]]+ ;; Explicitly bin the rating field to ensure we get BigDecimal values+ ;; from the QP+ :breakout [$id [:field $rating {:binning {:strategy :default}}]]+ :limit 3})}]+ (let [result (card-download card {:export-format :csv :format-rows false :pivot true})]+ ;; Verify we get some actual results, not all empty cells for the pivot values+ (is (= [["1" "29.46" "" "" "29.46"]+ ["2" "" "70.08" "" "70.08"]+ ["3" "" "" "35.39" "35.39"]+ ["Grand totals" "" "" "" "55.7464"]]+ (rest result))))))))