 (defmulti ^:private post-process query-type-dispatch-fn)
 
 (defmethod post-process ::select     [_ results] (->> results first :result :events (map :event)))
-(defmethod post-process ::timeseries [_ results] (map :result results))
+(defmethod post-process ::total [_ results] (map :result results))
 (defmethod post-process ::topN       [_ results] (-> results first :result))
 (defmethod post-process ::groupBy    [_ results] (map :event results))
+
+(defmethod post-process ::grouped-timeseries [_ results]
+  (->> results
+    (map (fn [event]
+      (conj {:timestamp (:timestamp event)} (:result event)))))
 
 (defn post-process-native
   "Post-process the results of a *native* Druid query.

                    0 :none
                    1 :one
                      :many)
        agg?      (boolean (and ag-type (not= ag-type :rows)))]
    (match [breakouts agg?]
      [:none false] ::select
      [:none  true] ::timeseries
      [:one      _] ::topN
      [:many     _] ::groupBy)))


(defn- build-druid-query [query]

                                               RelativeDateTimeValue
                                               Value)))


;;             +-----> ::select      +----> :groupBy
;; ::query ----|                     |
;;             +----> ::ag-query ----+----> ::topN
;;                                   |                       +----> total
;;                                   +----> ::timeseries ----|
;;                                                           +----> grouped-timeseries

(derive ::select             ::query)
(derive ::ag-query           ::query)
(derive ::topN               ::ag-query)
(derive ::groupBy            ::ag-query)
(derive ::timeseries         ::ag-query)
(derive ::total              ::timeseries)
(derive ::grouped-timeseries ::timeseries)

(def ^:private ^:dynamic *query*
  "The INNER part of the query currently being processed.
