                    :histogram
                    (let [interval (-> agg-data :interval float)]
                      [{:agg (format "FLOOR(%s / %.1f)" field interval)
-                       :col (gen-col-name field "hist" (:interval agg-data))}])
+                       :col (gen-col-name "hist")}])
                    
                    :date_histogram
                    (let [_            (assert (= \d (-> agg-data :interval last)) "Only days are supported for now")
-                         interval     (-> agg-data :interval butlast (#(Float. (apply str %))))
+                         to-float     (fn [^String s] (Float. s))
+                         interval     (->> agg-data :interval butlast (apply str) to-float)
                          interval-div (if (= 1.0 interval) "" (format " / %.1f" interval))]
                      [{:agg (format "FLOOR(CAST(CAST(%s AS datetime) AS float)%s)" field interval-div)
-                       :col (gen-col-name field "datehist" (:interval agg-data))}]))}
+                       :col (gen-col-name "datehist")}]))}
                 
                 {:metrics
                  (cond

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn run-benchmark [benchmark-fn filter-generators aggregations n-tries n-parallels]
  (let [percentiles (partial percentiles [5 10 25 50 75 90 95])]
    (doall (for [n-parallel                     n-parallels
                 [filter-name filter-generator] filter-generators
                 [aggregation-name aggregation] aggregations]

  (let [client       (make-client)
        benchmark-fn (fn [filter-generator aggregation]
                       (let [t-start (System/nanoTime)
                             result  (try
                                       (->> (filter-generator) aggregation (run-query client))
                                       (catch java.io.IOException e nil))
                             t-end   (System/nanoTime)]
                         {:took (- t-end t-start)
                        ; :result result
                          :hits (some-> result :body :hits :total)}))]
    (apply run-benchmark benchmark-fn args)))

(comment
  (let [results (benchmark-es filters aggregations 500 [1 2 4])]
    (spit "results_es.edn" (with-out-str (clojure.pprint/pprint results)))
    (println "")
    (clojure.pprint/pprint results)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

