Skip to content

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

Fix pivot table drill through when binning a datetime by day (#70680)

Kevin Kelleher2a4046736a0f
diff --git a/src/metabase/pivot/js.cljs b/src/metabase/pivot/js.cljs
index b951fb32739..5bf1a78535c 100644
--- a/src/metabase/pivot/js.cljs
+++ b/src/metabase/pivot/js.cljs
@@ -2,6 +2,7 @@
"Javascript-facing interface for pivot table postprocessing. Wraps functions in metabase.pivot.core."
(:require
[metabase.pivot.core :as pivot]
+ [metabase.util :as u]
[metabase.util.performance :as perf]))
(defn ^:export columns-without-pivot-group
@@ -9,7 +10,8 @@
[cols]
(let [cols (js->clj cols :keywordize-keys true)]
(clj->js
- (pivot/columns-without-pivot-group cols))))
+ (pivot/columns-without-pivot-group cols)
+ :keyword-fn u/qualified-name)))
(defn ^:export split-pivot-data
"Pulls apart different aggregations that were packed into one result set returned from the QP.
diff --git a/test/metabase/pivot/js_test.cljs b/test/metabase/pivot/js_test.cljs
new file mode 100644
index 00000000000..a5ee86cd61c
--- /dev/null
+++ b/test/metabase/pivot/js_test.cljs
@@ -0,0 +1,16 @@
+(ns metabase.pivot.js-test
+ (:require
+ [clojure.test :refer [deftest is testing]]
+ [metabase.pivot.js :as pivot.js]))
+
+(deftest ^:parallel columns-without-pivot-group-preserves-namespaced-keys-test
+ (testing "Namespaced keys like lib/breakout? survive the JS->CLJS->JS round-trip (#70358)"
+ (let [input #js [#js {"name" "CREATED_AT"
+ "lib/breakout?" true}
+ #js {"name" "pivot-grouping"}]
+ result (pivot.js/columns-without-pivot-group input)
+ col (first result)]
+ (is (= 1 (.-length result)))
+ (is (= "CREATED_AT" (unchecked-get col "name")))
+ (is (true? (unchecked-get col "lib/breakout?"))
+ "namespaced key lib/breakout? should be preserved through CLJS conversion"))))