 (ns metabase.query-processor-test.expression-aggregations-test
   "Tests for expression aggregations and for named aggregations."
   (:require [expectations :refer :all]
+            [metabase.driver :as driver]
             [metabase.models.metric :refer [Metric]]
             [metabase.query-processor :as qp]
             [metabase.query-processor.expand :as ql]
             [metabase.query-processor-test :refer :all]
             [metabase.test.data :as data]
-            [metabase.test.data.datasets :as datasets, :refer [*engine*]]
+            [metabase.test.data.datasets :as datasets, :refer [*engine* *driver*]]
             [metabase.test.util :as tu]
             [metabase.util :as u]))
 

             [3  39]
             [4  24]]
   :columns [(data/format-name "price")
             (if (= *engine* :redshift) "my cool metric" "My Cool Metric")]}
  (tu/with-temp Metric [metric {:table_id   (data/id :venues)
                                :definition {:aggregation [[:sum [:field-id (data/id :venues :price)]]]
                                             :filter      [:> [:field-id (data/id :venues :price)] 1]}}]

             [3  52]
             [4  30]]
   :columns [(data/format-name "price")
             (driver/format-custom-field-name *driver* "New Price")]} ; Redshift annoyingly always lowercases column aliases
  (format-rows-by [int int]
    (rows+column-names (data/run-query venues
                         (ql/aggregation (ql/named (ql/sum (ql/+ $price 1)) "New Price"))
