#510 support :timeseries :auto

This commit is contained in:
Sean Corfield 2023-10-21 15:42:11 -07:00
parent caca08fd5b
commit 10b2a17718

View file

@ -1313,15 +1313,18 @@
[(str/join ", " (mapv #(str (sql-kw k) " " %) tables))])) [(str/join ", " (mapv #(str (sql-kw k) " " %) tables))]))
(defn- format-interval (defn- format-interval
[k [n & units]] [k args]
(if (seq units) (if (sequential? args)
(let [[sql & params] (format-expr n)] (let [[n & units] args]
(into [(str (sql-kw k) " " sql " " (if (seq units)
(str/join " " (map sql-kw units)))] (let [[sql & params] (format-expr n)]
params)) (into [(str (sql-kw k) " " sql " "
(binding [*inline* true] (str/join " " (map sql-kw units)))]
(let [[sql & params] (format-expr n)] params))
(into [(str (sql-kw k) " " sql)] params))))) (binding [*inline* true]
(let [[sql & params] (format-expr n)]
(into [(str (sql-kw k) " " sql)] params)))))
[(str (sql-kw k) " " (sql-kw args))]))
(defn- check-where (defn- check-where
"Given a formatter function, performs a pre-flight check that there is "Given a formatter function, performs a pre-flight check that there is
a non-empty where clause if at least basic checking is enabled." a non-empty where clause if at least basic checking is enabled."
@ -2326,7 +2329,7 @@
(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] ;; :timeseries :auto supported as a shortcut:
(sql/format {:select :col :from :data :timeseries :auto} {:dialect :nrql}) (sql/format {:select :col :from :data :timeseries :auto} {:dialect :nrql})
(sql/format {:select [[[:latest (keyword "Elastic/Search OK Count/value")]] (sql/format {:select [[[:latest (keyword "Elastic/Search OK Count/value")]]
[[:latest (keyword "Elastic/Search Fail Count/value")]] [[:latest (keyword "Elastic/Search Fail Count/value")]]