Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Update backend docs on Thu Feb 15 17:24:07 UTC 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Feb 15, 2024
1 parent c082a4f commit 696620d
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30006,15 +30006,25 @@ <h1>How to use and extend this method?</h1>
[metabase.util.malli.schema :as ms])
(:import
(java.time.temporal Temporal)))</pre></td></tr><tr><td class="docs">
</td><td class="codes"><pre class="brush: clojure">(set! *warn-on-reflection* true)</pre></td></tr><tr><td class="docs"><p>Is param type <code>:date</code> or some subtype like <code>:date/month-year</code>?</p>
</td><td class="codes"><pre class="brush: clojure">(set! *warn-on-reflection* true)</pre></td></tr><tr><td class="docs">
</td><td class="codes"><pre class="brush: clojure">(def ^:private temporal-units-regex #&quot;(millisecond|second|minute|hour|day|week|month|quarter|year)&quot;)</pre></td></tr><tr><td class="docs"><p>Regex to match date exclusion values, e.g. exclude-days-Mon, exclude-months-Jan, etc.</p>
</td><td class="codes"><pre class="brush: clojure">(def date-exclude-regex
(re-pattern (str &quot;exclude-&quot; temporal-units-regex #&quot;s-([-\p{Alnum}]+)&quot;)))</pre></td></tr><tr><td class="docs"><p>Is param type <code>:date</code> or some subtype like <code>:date/month-year</code>?</p>
</td><td class="codes"><pre class="brush: clojure">(mu/defn date-type?
[param-type :- :keyword]
(= (get-in mbql.s/parameter-types [param-type :type]) :date))</pre></td></tr><tr><td class="docs"><p>Does date <code>param-type</code> represent a range of dates, rather than a single absolute date? (The value may be relative,
such as <code>past30days</code>, or absolute, such as <code>2020-01</code>.)</p>
</td><td class="codes"><pre class="brush: clojure">(defn not-single-date-type?
[param-type]
(and (date-type? param-type)
(not (#{:date/single :date} param-type))))</pre></td></tr><tr><td class="docs"><p>Both in MBQL and SQL parameter substitution a field value is compared to a date range, either relative or absolute.
(not (#{:date/single :date} param-type))))</pre></td></tr><tr><td class="docs"><p>When date <code>param-type</code> represent an exclusion of dates returns the temporal unit that's excluded.</p>
</td><td class="codes"><pre class="brush: clojure">(defn exclusion-date-type
[param-type value]
(when (and (date-type? param-type)
(string? value))
(some-&gt;&gt; (re-matches date-exclude-regex value)
second
keyword)))</pre></td></tr><tr><td class="docs"><p>Both in MBQL and SQL parameter substitution a field value is compared to a date range, either relative or absolute.
Currently the field value is casted to a day (ignoring the time of day), so the ranges should have the same
granularity level.</p>

Expand Down Expand Up @@ -30112,8 +30122,7 @@ <h1>How to use and extend this method?</h1>
2) Range decoder which takes the parser output and produces a date range relative to the given datetime
3) Filter decoder which takes the parser output and produces a mbql clause for a given mbql field reference</p>
</td><td class="codes"></td></tr><tr><td class="docs">
</td><td class="codes"><pre class="brush: clojure">(def ^:private temporal-units-regex #&quot;(millisecond|second|minute|hour|day|week|month|quarter|year)&quot;)
(def ^:private relative-suffix-regex (re-pattern (format &quot;(|~|-from-([0-9]+)%ss)&quot; temporal-units-regex)))</pre></td></tr><tr><td class="docs"><p>Adding a tilde (~) at the end of a past<n><unit>s filter means we should include the current time-unit (e.g. year, day,
</td><td class="codes"><pre class="brush: clojure">(def ^:private relative-suffix-regex (re-pattern (format &quot;(|~|-from-([0-9]+)%ss)&quot; temporal-units-regex)))</pre></td></tr><tr><td class="docs"><p>Adding a tilde (~) at the end of a past<n><unit>s filter means we should include the current time-unit (e.g. year, day,
week, or month).</p>
</td><td class="codes"><pre class="brush: clojure">(defn- include-current?
[relative-suffix]
Expand Down Expand Up @@ -30231,9 +30240,7 @@ <h1>How to use and extend this method?</h1>
{:hour :hour-of-day
:day :day-of-week
:month :month-of-year
:quarter :quarter-of-year})</pre></td></tr><tr><td class="docs"><p>Regex to match date exclusion values, e.g. exclude-days-Mon, exclude-months-Jan, etc.</p>
</td><td class="codes"><pre class="brush: clojure">(def date-exclude-regex
(re-pattern (str &quot;exclude-&quot; temporal-units-regex #&quot;s-([-\p{Alnum}]+)&quot;)))</pre></td></tr><tr><td class="docs">
:quarter :quarter-of-year})</pre></td></tr><tr><td class="docs">
</td><td class="codes"><pre class="brush: clojure">(defn- absolute-date-&gt;unit
[date-string]
(if (str/includes? date-string &quot;T&quot;)
Expand Down Expand Up @@ -36820,6 +36827,7 @@ <h6>`:abstract?` (default = false)</h6>
:as qp.wrap-value-literals]
[metabase.query-processor.timezone :as qp.timezone]
[metabase.query-processor.util.add-alias-info :as add]
[metabase.shared.util.time :as shared.ut]
[metabase.util :as u]
[metabase.util.date-2 :as u.date]
[metabase.util.i18n :refer [tru]]
Expand Down Expand Up @@ -36891,9 +36899,17 @@ <h6>`:abstract?` (default = false)</h6>
(when (params.dates/date-type? param-type)
:day))</pre></td></tr><tr><td class="docs">
</td><td class="codes"><pre class="brush: clojure">(defmethod align-temporal-unit-with-param-type-and-value :default
[driver field param-type _value]
#_{:clj-kondo/ignore [:deprecated-var]}
(align-temporal-unit-with-param-type driver field param-type))</pre></td></tr><tr><td class="docs"><p>------------------------------------------- ->replacement-snippet-info -------------------------------------------</p>
[_driver _field param-type value]
(when (params.dates/date-type? param-type)
(if-let [exclusion-type (params.dates/exclusion-date-type param-type value)]
exclusion-type
(let [value* (if (params.dates/not-single-date-type? param-type)
(let [param-range (params.dates/date-string-&gt;range value)]
(or (:start param-range) (:end param-range))) ;; Before or after filters only have one of these
value)]
(if (re-matches shared.ut/local-date-regex value*)
:day
:minute)))))</pre></td></tr><tr><td class="docs"><p>------------------------------------------- ->replacement-snippet-info -------------------------------------------</p>
</td><td class="codes"></td></tr><tr><td class="docs">
</td><td class="codes"><pre class="brush: clojure">(def ^:private ParamSnippetInfo
[:map
Expand Down Expand Up @@ -37039,9 +37055,7 @@ <h6>`:abstract?` (default = false)</h6>
qp.wrap-value-literals/wrap-value-literals-in-mbql
-&gt;honeysql
(honeysql-&gt;replacement-snippet-info driver))
(and (params.dates/date-type? param-type)
(string? value)
(re-matches params.dates/date-exclude-regex value))
(params.dates/exclusion-date-type param-type value)
(let [field-clause (field-&gt;clause driver field param-type value)]
(-&gt;&gt; (params.dates/date-string-&gt;filter value field-clause)
mbql.u/desugar-filter-clause
Expand Down

0 comments on commit 696620d

Please sign in to comment.