Skip to content

Commit

Permalink
Support more druid postaggregations. (#2235)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkyryliuk authored Feb 24, 2017
1 parent ede4dff commit 3018356
Showing 1 changed file with 27 additions and 4 deletions.
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,

This comment has been minimized.

Copy link
@ascott

ascott Feb 24, 2017

@bkyryliuk i'm getting these errors run trying to start the server now

from pydruid.utils.postaggregator import (
ImportError: cannot import name Quantile
[2017-02-24 12:32:30 -0800] [27444] [INFO] Worker exiting (pid: 27444)
Traceback (most recent call last):
  File "/usr/local/bin/gunicorn", line 11, in <module>
    load_entry_point('gunicorn', 'console_scripts', 'gunicorn')()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 192, in run
    super(Application, self).run()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
    Arbiter(self).run()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 218, in run
    self.halt(reason=inst.reason, exit_status=inst.exit_status)
  File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 331, in halt
    self.stop()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 381, in stop
    time.sleep(0.1)
  File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 231, in handle_chld
    self.reap_workers()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 506, in reap_workers
    raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
)
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

0 comments on commit 3018356

Please sign in to comment.