Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support more druid post aggregations. #2235

Merged
merged 1 commit into from
Feb 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions superset/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
from pydruid.client import PyDruid
from pydruid.utils.aggregators import count
from pydruid.utils.filters import Dimension, Filter
from pydruid.utils.postaggregator import Postaggregator
from pydruid.utils.postaggregator import (
Postaggregator, Quantile, Quantiles, Field, Const, HyperUniqueCardinality,
)
from pydruid.utils.having import Aggregation
from six import string_types

Expand Down Expand Up @@ -2354,9 +2356,30 @@ def recursive_get_fields(_conf):
all_metrics += conf.get('fieldNames', [])
if conf.get('type') == 'javascript':
post_aggs[metric_name] = JavascriptPostAggregator(
name=conf.get('name'),
field_names=conf.get('fieldNames'),
function=conf.get('function'))
name=conf.get('name', ''),
field_names=conf.get('fieldNames', []),
function=conf.get('function', ''))
elif conf.get('type') == 'quantile':
post_aggs[metric_name] = Quantile(
conf.get('name', ''),
conf.get('probability', ''),
)
elif conf.get('type') == 'quantiles':
post_aggs[metric_name] = Quantiles(
conf.get('name', ''),
conf.get('probabilities', ''),
)
elif conf.get('type') == 'fieldAccess':
post_aggs[metric_name] = Field(conf.get('name'), '')
elif conf.get('type') == 'constant':
post_aggs[metric_name] = Const(
conf.get('value'),
output_name=conf.get('name', '')
)
elif conf.get('type') == 'hyperUniqueCardinality':
post_aggs[metric_name] = HyperUniqueCardinality(
conf.get('name'), ''
)
else:
post_aggs[metric_name] = Postaggregator(
conf.get('fn', "/"),
Expand Down