mistercrunch closed pull request #4044: [druid] add support for 'select' queries
URL: https://github.com/apache/incubator-superset/pull/4044
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/superset/connectors/druid/models.py
b/superset/connectors/druid/models.py
index a666253f26..3ebb33ab88 100644
--- a/superset/connectors/druid/models.py
+++ b/superset/connectors/druid/models.py
@@ -1001,7 +1001,6 @@ def run_query( # noqa / druid
inner_from_dttm=None, inner_to_dttm=None,
orderby=None,
extras=None, # noqa
- select=None, # noqa
columns=None, phase=2, client=None, form_data=None,
order_desc=True):
"""Runs a query against Druid and returns a dataframe.
@@ -1056,7 +1055,17 @@ def run_query( # noqa / druid
order_direction = 'descending' if order_desc else 'ascending'
- if len(groupby) == 0 and not having_filters:
+ if columns:
+ del qry['post_aggregations']
+ del qry['aggregations']
+ qry['dimensions'] = columns
+ qry['metrics'] = []
+ qry['granularity'] = 'all'
+ qry['paging_spec'] = {
+ 'threshold': row_limit,
+ }
+ client.select(**qry)
+ elif len(groupby) == 0 and not having_filters:
logging.info('Running timeseries query for no groupby values')
del qry['dimensions']
client.timeseries(**qry)
@@ -1195,8 +1204,11 @@ def query(self, query_obj):
cols = []
if DTTM_ALIAS in df.columns:
cols += [DTTM_ALIAS]
- cols += [col for col in query_obj['groupby'] if col in df.columns]
- cols += [col for col in query_obj['metrics'] if col in df.columns]
+ cols += query_obj.get('groupby') or []
+ cols += query_obj.get('columns') or []
+ cols += query_obj.get('metrics') or []
+
+ cols = [col for col in cols if col in df.columns]
df = df[cols]
time_offset = DruidDatasource.time_offset(query_obj['granularity'])
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services