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

[MLv2] Include temporal-bucketing on selected join condition columns (#33138)


* [MLv2] Include temporal-bucketing on selected join condition columns

* Update test/metabase/lib/join_test.cljc

Co-authored-by: default avatarmetamben <103100869+metamben@users.noreply.github.com>

---------

Co-authored-by: default avatarmetamben <103100869+metamben@users.noreply.github.com>
parent b1c0b504
No related branches found
No related tags found
No related merge requests found
......@@ -676,7 +676,13 @@
(defn- mark-selected-column [metadata-providerable existing-column-or-nil columns]
(if-not existing-column-or-nil
columns
(lib.equality/mark-selected-columns metadata-providerable columns [existing-column-or-nil])))
(mapv (fn [column]
(if (:selected? column)
(lib.temporal-bucket/with-temporal-bucket
column
(lib.temporal-bucket/temporal-bucket existing-column-or-nil))
column))
(lib.equality/mark-selected-columns metadata-providerable columns [existing-column-or-nil]))))
(mu/defn join-condition-lhs-columns :- [:sequential lib.metadata/ColumnMetadata]
"Get a sequence of columns that can be used as the left-hand-side (source column) in a join condition. This column
......
......@@ -1124,4 +1124,9 @@
{:name "RATING", :selected? false}
{:name "CREATED_AT", :selected? true}]
(mapv #(select-keys % [:name :selected?])
(lib/join-condition-rhs-columns query join lhs rhs)))))))))
(lib/join-condition-rhs-columns query join lhs rhs))))))
(testing "temporal bucket returns with column metadata"
(let [[lhs-column] (filter :selected? (lib/join-condition-lhs-columns query 0 join lhs rhs))]
(is (= {:lib/type :option/temporal-bucketing, :unit :month} (lib/temporal-bucket lhs-column))))
(let [[rhs-column] (filter :selected? (lib/join-condition-rhs-columns query 0 join lhs rhs))]
(is (= {:lib/type :option/temporal-bucketing, :unit :month} (lib/temporal-bucket rhs-column))))))))
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