Skip to content
Snippets Groups Projects
Unverified Commit f21baa7c authored by Braden Shepherdson's avatar Braden Shepherdson Committed by GitHub
Browse files

[MLv2] Add `:is_source_table` to the display info `table` field (#30003)

Fixes #29989
parent 6a0eb5c3
No related branches found
No related tags found
No related merge requests found
......@@ -234,7 +234,9 @@
[:is_calculated {:optional true} [:maybe :boolean]]
;; if this is a Column, is it an implicitly joinable one? I.e. is it from a different table that we have not
;; already joined, but could implicitly join against?
[:is_implicitly_joinable {:optional true} [:maybe :boolean]]])
[:is_implicitly_joinable {:optional true} [:maybe :boolean]]
;; For the `:table` field of a Column, is this the source table, or a joined table?
[:is_source_table {:optional true} [:maybe :boolean]]])
(mu/defn display-info :- ::display-info
"Given some sort of Cljs object, return a map with the info you'd need to implement UI for it. This is mostly meant to
......@@ -272,3 +274,8 @@
(defmethod display-info-method :default
[query stage-number x]
(default-display-info query stage-number x))
(defmethod display-info-method :metadata/table
[query stage-number table]
(merge (default-display-info query stage-number table)
{:is_source_table (= (lib.util/source-table query) (:id table))}))
......@@ -375,3 +375,8 @@
(when (string? table-id)
(when-let [[_match card-id-str] (re-find #"^card__(\d+)$" table-id)]
(parse-long card-id-str))))
(mu/defn source-table :- [:maybe ::lib.schema.id/table]
"If this query has a `:source-table`, return it."
[query]
(-> query :stages first :source-table))
......@@ -628,20 +628,27 @@
(let [query (lib/query-for-table-name meta/metadata-provider "VENUES")]
(is (=? [{:semantic_type :type/PK
:is_calculated false
:table {:name "VENUES", :display_name "Venues"}
:table {:name "VENUES", :display_name "Venues" :is_source_table true}
:name "ID"
:is_from_previous_stage false
:is_implicitly_joinable false
:effective_type :type/BigInteger
:is_from_join false
:display_name "ID"}
{:display_name "Name"}
{:display_name "Category ID"}
{:display_name "Latitude"}
{:display_name "Longitude"}
{:display_name "Price"}
{:display_name "ID"}
{:display_name "Name"}]
{:display_name "Name"
:table {:is_source_table true}}
{:display_name "Category ID"
:table {:is_source_table true}}
{:display_name "Latitude"
:table {:is_source_table true}}
{:display_name "Longitude"
:table {:is_source_table true}}
{:display_name "Price"
:table {:is_source_table true}}
{:display_name "ID"
:table {:name "CATEGORIES" :display_name "Categories" :is_source_table false}}
{:display_name "Name"
:table {:name "CATEGORIES" :display_name "Categories" :is_source_table false}}]
(for [col (lib/orderable-columns query)]
(lib/display-info query col))))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment