Skip to content

Commit 3018356

Browse files
authored
Support more druid postaggregations. (#2235)
1 parent ede4dff commit 3018356

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

superset/models.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
from pydruid.client import PyDruid
3838
from pydruid.utils.aggregators import count
3939
from pydruid.utils.filters import Dimension, Filter
40-
from pydruid.utils.postaggregator import Postaggregator
40+
from pydruid.utils.postaggregator import (
41+
Postaggregator, Quantile, Quantiles, Field, Const, HyperUniqueCardinality,
42+
)
4143
from pydruid.utils.having import Aggregation
4244
from six import string_types
4345

@@ -2354,9 +2356,30 @@ def recursive_get_fields(_conf):
23542356
all_metrics += conf.get('fieldNames', [])
23552357
if conf.get('type') == 'javascript':
23562358
post_aggs[metric_name] = JavascriptPostAggregator(
2357-
name=conf.get('name'),
2358-
field_names=conf.get('fieldNames'),
2359-
function=conf.get('function'))
2359+
name=conf.get('name', ''),
2360+
field_names=conf.get('fieldNames', []),
2361+
function=conf.get('function', ''))
2362+
elif conf.get('type') == 'quantile':
2363+
post_aggs[metric_name] = Quantile(
2364+
conf.get('name', ''),
2365+
conf.get('probability', ''),
2366+
)
2367+
elif conf.get('type') == 'quantiles':
2368+
post_aggs[metric_name] = Quantiles(
2369+
conf.get('name', ''),
2370+
conf.get('probabilities', ''),
2371+
)
2372+
elif conf.get('type') == 'fieldAccess':
2373+
post_aggs[metric_name] = Field(conf.get('name'), '')
2374+
elif conf.get('type') == 'constant':
2375+
post_aggs[metric_name] = Const(
2376+
conf.get('value'),
2377+
output_name=conf.get('name', '')
2378+
)
2379+
elif conf.get('type') == 'hyperUniqueCardinality':
2380+
post_aggs[metric_name] = HyperUniqueCardinality(
2381+
conf.get('name'), ''
2382+
)
23602383
else:
23612384
post_aggs[metric_name] = Postaggregator(
23622385
conf.get('fn', "/"),

0 commit comments

Comments
 (0)