From 9924a783612b67ecb0c1f37cee886f697f69df0a Mon Sep 17 00:00:00 2001 From: Cam Saul <1455846+camsaul@users.noreply.github.com> Date: Tue, 4 Apr 2023 13:30:13 -0700 Subject: [PATCH] MLv2: Fix `:relative-datetime` schema (#29769) --- src/metabase/lib/schema/expression/temporal.cljc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/metabase/lib/schema/expression/temporal.cljc b/src/metabase/lib/schema/expression/temporal.cljc index f63fda260fa..aca53e0b8a9 100644 --- a/src/metabase/lib/schema/expression/temporal.cljc +++ b/src/metabase/lib/schema/expression/temporal.cljc @@ -2,7 +2,8 @@ (:require [metabase.lib.schema.expression :as expression] [metabase.lib.schema.mbql-clause :as mbql-clause] - [metabase.lib.schema.temporal-bucketing :as temporal-bucketing])) + [metabase.lib.schema.temporal-bucketing :as temporal-bucketing] + [metabase.util.malli.registry :as mr])) (mbql-clause/define-tuple-mbql-clause :interval :int @@ -51,9 +52,14 @@ #_:datetimestr [:schema [:ref ::expression/string]] #_:unit [:ref ::temporal-bucketing/unit.date-time.interval]) +(mr/def ::relative-datetime.amount + [:or + [:= :current] + :int]) + (mbql-clause/define-tuple-mbql-clause :relative-datetime :- :type/DateTime - #_:datetimestr [:schema [:ref ::expression/string]] - #_:unit [:ref ::temporal-bucketing/unit.date-time.interval]) + #_n [:ref ::relative-datetime.amount] + #_unit [:ref ::temporal-bucketing/unit.date-time.interval]) (mbql-clause/define-tuple-mbql-clause :time :- :type/TimeWithTZ #_:timestr [:schema [:ref ::expression/string]] -- GitLab