Skip to content
Snippets Groups Projects
Commit 96421ca0 authored by Cam Saül's avatar Cam Saül Committed by GitHub
Browse files

Merge pull request #3868 from metabase/fix-expression-aggs-with-count

Fix expression aggregations for aggregation w/o field :wrench: [ci dr…
parents 2dd867a3 b9424b33
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@
[metabase.util.honeysql-extensions :as hx])
(:import java.sql.Timestamp
java.util.Date
clojure.lang.Keyword
(metabase.query_processor.interface AgFieldRef
DateTimeField
DateTimeValue
......@@ -65,7 +66,8 @@
nil (formatted [_] nil)
Number (formatted [this] this)
String (formatted [this] this)
honeysql.types.SqlCall (formatted [this] this)
Keyword (formatted [this] this) ; HoneySQL fn calls and keywords (e.g. `:%count.*`) are
honeysql.types.SqlCall (formatted [this] this) ; already converted to HoneySQL so just return them as-is
Expression
(formatted [{:keys [operator args]}]
......
......@@ -182,3 +182,13 @@
(ql/aggregation (ql/+ (ql/max $venue_price)
(ql/min (ql/- $venue_price $id))))
(ql/breakout $venue_price)))
;; aggregation w/o field
(expect-with-engine :druid
[["1" 222.0]
["2" 616.0]
["3" 116.0]
["4" 50.0]]
(druid-query-returning-rows
(ql/aggregation (ql/+ 1 (ql/count)))
(ql/breakout $venue_price)))
......@@ -134,3 +134,14 @@
(ql/aggregation (ql/+ (ql/max $price)
(ql/min (ql/- $price $id))))
(ql/breakout $price)))))
;; aggregation w/o field
(datasets/expect-with-engines (engines-that-support :expression-aggregations)
[[1 23]
[2 60]
[3 14]
[4 7]]
(format-rows-by [int int]
(rows (data/run-query venues
(ql/aggregation (ql/+ 1 (ql/count)))
(ql/breakout $price)))))
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