Skip to content
Snippets Groups Projects
Unverified Commit bbcabdff authored by Case Nelson's avatar Case Nelson Committed by GitHub
Browse files

[MLv2] Column metadata to legacy-field-ref (#33623)

* [MLv2] Column metadata to legacy-field-ref

Fixes #33622

Pulled from https://github.com/metabase/metabase/pull/32698



* [experimental] Allow selecting MLv2 metadata directly from app DB using Toucan 2 shenanigans

* Fix file that changed in merge

---------

Co-authored-by: default avatarCam Saul <github@camsaul.com>
parent 7fbccf6d
Branches
Tags
No related merge requests found
......@@ -9,7 +9,7 @@
[filter])
(:require
[medley.core :as m]
[metabase.lib.convert :as convert]
[metabase.lib.convert :as lib.convert]
[metabase.lib.core :as lib.core]
[metabase.lib.equality :as lib.equality]
[metabase.lib.join :as lib.join]
......@@ -65,7 +65,7 @@
<>
(assoc <> :type :query))
(mbql.normalize/normalize <>)
(convert/->pMBQL <>)))
(lib.convert/->pMBQL <>)))
(defn ^:export metadataProvider
"Convert metadata to a metadata provider if it is not one already."
......@@ -98,7 +98,7 @@
(defn ^:export legacy-query
"Coerce a CLJS pMBQL query back to (1) a legacy query (2) in vanilla JS."
[query-map]
(-> query-map convert/->legacy-MBQL fix-namespaced-values (clj->js :keyword-fn u/qualified-name)))
(-> query-map lib.convert/->legacy-MBQL fix-namespaced-values (clj->js :keyword-fn u/qualified-name)))
(defn ^:export append-stage
"Adds a new blank stage to the end of the pipeline"
......@@ -496,7 +496,7 @@
[column]
(-> column
lib.core/ref
convert/->legacy-MBQL
lib.convert/->legacy-MBQL
(update 2 update-vals #(if (qualified-keyword? %)
(u/qualified-name %)
%))
......@@ -506,7 +506,7 @@
(-> legacy-ref
(js->clj :keywordize-keys true)
(update 0 keyword)
convert/->pMBQL))
lib.convert/->pMBQL))
(defn- ->column-or-ref [column]
(if-let [^js legacy-column (when (object? column) column)]
......@@ -524,9 +524,9 @@
Returns a parallel list to the refs, with the corresponding index, or -1 if no matching column is found."
[a-query stage-number legacy-columns legacy-refs]
;; Set up this query stage's `:aggregation` list as the context for [[convert/->pMBQL]] to convert legacy
;; Set up this query stage's `:aggregation` list as the context for [[lib.convert/->pMBQL]] to convert legacy
;; `[:aggregation 0]` refs into pMBQL `[:aggregation uuid]` refs.
(convert/with-aggregation-list (:aggregation (lib.util/query-stage a-query stage-number))
(lib.convert/with-aggregation-list (:aggregation (lib.util/query-stage a-query stage-number))
(let [haystack (mapv ->column-or-ref legacy-columns)
needles (map legacy-ref->pMBQL legacy-refs)]
#_{:clj-kondo/ignore [:discouraged-var]}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment