mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
Recursively get the dependency fields of post aggregators (#437)
This commit is contained in:
parent
6941f1de64
commit
bc7170769b
@ -1062,16 +1062,26 @@ class DruidDatasource(Model, AuditMixinNullable, Queryable):
|
||||
metrics_dict = {m.metric_name: m for m in self.metrics}
|
||||
all_metrics = []
|
||||
post_aggs = {}
|
||||
|
||||
def recursive_get_fields(_conf):
|
||||
_fields = _conf.get('fields', [])
|
||||
field_names = []
|
||||
for _f in _fields:
|
||||
_type = _f.get('type')
|
||||
if _type == 'fieldAccess':
|
||||
field_names.append(_f.get('fieldName'))
|
||||
elif _type == 'arithmetic':
|
||||
field_names += recursive_get_fields(_f)
|
||||
|
||||
return list(set(field_names))
|
||||
|
||||
for metric_name in metrics:
|
||||
metric = metrics_dict[metric_name]
|
||||
if metric.metric_type != 'postagg':
|
||||
all_metrics.append(metric_name)
|
||||
else:
|
||||
conf = metric.json_obj
|
||||
fields = conf.get('fields', [])
|
||||
all_metrics += [
|
||||
f.get('fieldName') for f in fields
|
||||
if f.get('type') == 'fieldAccess']
|
||||
all_metrics += recursive_get_fields(conf)
|
||||
all_metrics += conf.get('fieldNames', [])
|
||||
if conf.get('type') == 'javascript':
|
||||
post_aggs[metric_name] = JavascriptPostAggregator(
|
||||
|
Loading…
Reference in New Issue
Block a user