#510 basic facet support
This commit is contained in:
parent
2c6b89751d
commit
5e9bdba777
2 changed files with 23 additions and 2 deletions
|
|
@ -63,6 +63,8 @@
|
||||||
:join :left-join :right-join :inner-join :outer-join :full-join
|
:join :left-join :right-join :inner-join :outer-join :full-join
|
||||||
:cross-join
|
:cross-join
|
||||||
:where :group-by :having
|
:where :group-by :having
|
||||||
|
;; NRQL extension:
|
||||||
|
:facet
|
||||||
:window :partition-by
|
:window :partition-by
|
||||||
:order-by :limit :offset :fetch :for :lock :values
|
:order-by :limit :offset :fetch :for :lock :values
|
||||||
:on-conflict :on-constraint :do-nothing :do-update-set :on-duplicate-key-update
|
:on-conflict :on-constraint :do-nothing :do-update-set :on-duplicate-key-update
|
||||||
|
|
@ -676,8 +678,8 @@
|
||||||
(defn- format-selects [k xs]
|
(defn- format-selects [k xs]
|
||||||
(format-selects-common
|
(format-selects-common
|
||||||
(sql-kw k)
|
(sql-kw k)
|
||||||
(#{:select :select-distinct :from :window :delete-from
|
(#{:select :select-distinct :from :window :delete-from :facet
|
||||||
'select 'select-distinct 'from 'window 'delete-from}
|
'select 'select-distinct 'from 'window 'delete-from 'facet}
|
||||||
k)
|
k)
|
||||||
xs))
|
xs))
|
||||||
|
|
||||||
|
|
@ -1445,6 +1447,7 @@
|
||||||
:returning #'format-selects
|
:returning #'format-selects
|
||||||
:with-data #'format-with-data
|
:with-data #'format-with-data
|
||||||
;; NRQL extensions:
|
;; NRQL extensions:
|
||||||
|
:facet #'format-selector
|
||||||
:since #'format-interval
|
:since #'format-interval
|
||||||
:until #'format-interval
|
:until #'format-interval
|
||||||
:compare-with #'format-interval
|
:compare-with #'format-interval
|
||||||
|
|
@ -2319,4 +2322,17 @@
|
||||||
(sql/format-expr [:over [[:array_agg {:expr [:respect-nulls :a] :order-by :a
|
(sql/format-expr [:over [[:array_agg {:expr [:respect-nulls :a] :order-by :a
|
||||||
:limit 10}]
|
:limit 10}]
|
||||||
{:partition-by :something}]])
|
{:partition-by :something}]])
|
||||||
|
;; doesn't work yet -- requires [:auto]
|
||||||
|
(sql/format {:select :col :from :data :timeseries :auto} {:dialect :nrql})
|
||||||
|
(sql/format {:select [[[:latest (keyword "Elastic/Search OK Count/value")]]
|
||||||
|
[[:latest (keyword "Elastic/Search Fail Count/value")]]
|
||||||
|
[[:* 100 [:latest :Sent/rate]] "Sent/rate x 100"]]
|
||||||
|
:from :Metric
|
||||||
|
:where [:some :value]
|
||||||
|
#_[:and [:= :environment "production"]
|
||||||
|
[:= :process.name "match"]]
|
||||||
|
:facet [:some.metric :alias]
|
||||||
|
:since [1 :day :ago]
|
||||||
|
:timeseries [:auto]}
|
||||||
|
{:dialect :nrql})
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1020,6 +1020,11 @@
|
||||||
|
|
||||||
;; nrql-specific helpers:
|
;; nrql-specific helpers:
|
||||||
|
|
||||||
|
(defn facet
|
||||||
|
"(facet [:metric.name :alias])"
|
||||||
|
[& args]
|
||||||
|
(generic-1 :facet args))
|
||||||
|
|
||||||
(defn since
|
(defn since
|
||||||
"(since 2 :days :ago)"
|
"(since 2 :days :ago)"
|
||||||
[& args]
|
[& args]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue