From b0031069249ef59cbd0af280da2334a0dc87189e Mon Sep 17 00:00:00 2001 From: ganninu93 Date: Tue, 12 Dec 2017 15:43:33 +0100 Subject: [PATCH] Added support for "expression" in aggregators If numeric data is stored as String, one will not be able to perform aggregations on it. This fix provides a solution to this problem. Example: aggregations={"total": expression("amount", "doubleSum")}, will perform doubleSum on the "amount" field and return the result as "total" --- pydruid/utils/aggregators.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pydruid/utils/aggregators.py b/pydruid/utils/aggregators.py index fd4c5a79..c61ab584 100644 --- a/pydruid/utils/aggregators.py +++ b/pydruid/utils/aggregators.py @@ -67,6 +67,8 @@ def count(raw_metric): def hyperunique(raw_metric): return {"type": "hyperUnique", "fieldName": raw_metric} +def expression(raw_metric, aggregation): + return {"expression": "\""+raw_metric+"\"", "type":aggregation} def cardinality(raw_column, by_row=False): if type(raw_column) is not list: