Skip to content
Snippets Groups Projects
Unverified Commit 239847ef authored by metamben's avatar metamben Committed by GitHub
Browse files

Use keyword as datetime-diff units (#30439)

* Use keyword as datetime-diff units

Fixes #29897.

* Fix MLv2 round trip test

Fields with :base-type :type/Text are not considered temporal expressions
therefore :datetime-diff with such arguments is not a valid expression.
Such expressions removed by the clean step of the conversion to pMBQL.
parent 30cafcb2
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@
(mbql-clause/define-tuple-mbql-clause :datetime-diff :- :type/Integer
#_:datetime1 [:schema [:ref ::expression/temporal]]
#_:datetime2 [:schema [:ref ::expression/temporal]]
#_:unit [:enum "year" "month" "day" "hour" "second" "millisecond" "quarter"])
#_:unit [:ref ::temporal-bucketing/unit.date-time.truncate])
(mbql-clause/define-tuple-mbql-clause :get-week :- :type/Integer
#_:datetime [:schema [:ref ::expression/temporal]]
......
......@@ -1043,13 +1043,13 @@
{:database (mt/id)
:type :query
:query {:filter [:and
[:= a-str [:field "a_dt_tz_text" {:base-type :type/Text}]]
[:= b-str [:field "b_dt_tz_text" {:base-type :type/Text}]]]
[:= a-str [:field "a_dt_tz_text" {:base-type :type/DateTime}]]
[:= b-str [:field "b_dt_tz_text" {:base-type :type/DateTime}]]]
:expressions (into {}
(for [unit units]
[(name unit) [:datetime-diff
[:field "a_dt_tz" {:base-type :type/Text}]
[:field "b_dt_tz" {:base-type :type/Text}]
[:field "a_dt_tz" {:base-type :type/DateTime}]
[:field "b_dt_tz" {:base-type :type/DateTime}]
unit]]))
:fields (into [] (for [unit units]
[:expression (name unit)]))
......
......@@ -35,10 +35,6 @@
[legacy-query]
(or
*skip-conversion-tests*
;; #29897: `:datetime-diff` is not handled correctly.
(mbql.u/match-one legacy-query
:datetime-diff
"#29897")
;; #29904: `:fields` in `:joins` are supposed to be returned even if `:fields` is specified.
(mbql.u/match-one legacy-query
{:fields fields, :joins joins}
......
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