From b874e76dbc23bda5cb1b808830b09cddc661fd33 Mon Sep 17 00:00:00 2001 From: Guillaume Buisson Date: Fri, 5 Feb 2016 19:01:10 +0100 Subject: [PATCH] fixed filtered aggregator --- project.clj | 2 +- src/clj_druid/schemas/aggregation.clj | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/project.clj b/project.clj index 8704163..c38fe15 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject y42/clj-druid "0.2.10" +(defproject y42/clj-druid "0.2.11-SNAPSHOT" :description "Clojure library for Druid.io" :url "http://github.com/y42/clj-druid" :license {:name "Eclipse Public License" diff --git a/src/clj_druid/schemas/aggregation.clj b/src/clj_druid/schemas/aggregation.clj index 40c305a..73b537f 100644 --- a/src/clj_druid/schemas/aggregation.clj +++ b/src/clj_druid/schemas/aggregation.clj @@ -54,6 +54,21 @@ :name s/Str :fieldName s/Str}) +(s/defschema filteredAggregator + "A filtered aggregator wraps any given aggregator, but only aggregates the values for which the given dimension filter matches. +This makes it possible to compute the results of a filtered and an unfiltered aggregation simultaneously, without having to issue multiple queries, and use both results as part of post-aggregations." + {:type (s/enum :filtered) + :filter Filter + :aggregator (s/conditional + #(= :count (:type %)) countAggregator + #(= :longSum (:type %)) longSumAggregator + #(= :doubleSum (:type %)) doubleSumAggregator + #(= :min (:type %)) minAggregator + #(= :max (:type %)) maxAggregator + #(= :javascript (:type %)) javascriptAggregator + #(= :cardinality (:type %)) cardinalityAggregator + #(= :hyperUnique (:type %)) hyperUniqueAggregator)}) + (s/defschema aggregation "Aggregations are specifications of processing over metrics available in Druid" (s/conditional @@ -66,10 +81,5 @@ #(= :cardinality (:type %)) cardinalityAggregator #(= :hyperUnique (:type %)) hyperUniqueAggregator)) -(s/defschema filteredAggregator - "A filtered aggregator wraps any given aggregator, but only aggregates the values for which the given dimension filter matches. -This makes it possible to compute the results of a filtered and an unfiltered aggregation simultaneously, without having to issue multiple queries, and use both results as part of post-aggregations." - {:type (s/enum :filtered) - :filter Filter - :aggregator aggregation}) +