Skip to content

Commit

Permalink
[ad-hoc] Fixing type for count distinct (apache#7573)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-bodley authored May 22, 2019
1 parent efb085a commit 6b9790c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion superset/connectors/druid/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ def druid_type_from_adhoc_metric(adhoc_metric):
if aggregate == 'count':
return 'count'
if aggregate == 'count_distinct':
return 'cardinality'
return 'hyperUnique' if column_type == 'hyperunique' else 'cardinality'
else:
return column_type + aggregate.capitalize()

Expand Down
7 changes: 7 additions & 0 deletions tests/druid_func_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,13 @@ def test_druid_type_from_adhoc_metric(self):
})
assert(druid_type == 'cardinality')

druid_type = DruidDatasource.druid_type_from_adhoc_metric({
'column': {'type': 'hyperUnique', 'column_name': 'value'},
'aggregate': 'COUNT_DISTINCT',
'label': 'My Adhoc Metric',
})
assert(druid_type == 'hyperUnique')

def test_run_query_order_by_metrics(self):
client = Mock()
client.query_builder.last_query.query_dict = {'mock': 0}
Expand Down

0 comments on commit 6b9790c

Please sign in to comment.