Skip to content

Commit

Permalink
Skip derived metric with unsupport metric
Browse files Browse the repository at this point in the history
Signed-off-by: Wei-Chun, Chang <[email protected]>
  • Loading branch information
wcchang1115 committed Sep 5, 2023
1 parent c16c495 commit 48ed186
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions piperider_cli/dbtutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def is_chosen(key, metric):
for key, metric in manifest.get('metrics').items():
metric_map[metric.get('name')] = metric

def _create_metric(name, filter=None, alias=None):
def _create_metric(name, filter=None, alias=None, derived_metric=None):
statistics = Statistics()
metric = metric_map.get(name)

Expand Down Expand Up @@ -539,7 +539,8 @@ def _create_metric(name, filter=None, alias=None):
f['field'] = f['field'].replace(f'{primary_entity}__', '')
else:
console.print(
f"[[bold yellow]Skip[/bold yellow]] Metric '{metric.get('name')}'. "
f"[[bold yellow]Skip[/bold yellow]] "
f"Metric '{derived_metric if derived_metric else metric.get('name')}'. "
f"Dimension of foreign entities is not supported.")
statistics.add_field_one('nosupport')
return None
Expand All @@ -565,7 +566,11 @@ def _create_metric(name, filter=None, alias=None):
m2 = _create_metric(
ref_metric.get('name'),
filter=ref_metric.get('filter'),
alias=ref_metric.get('alias'))
alias=ref_metric.get('alias'),
derived_metric=metric.get('name')
)
if m2 is None:
return None
ref_metrics.append(m2)

derived_time_grains = find_derived_time_grains(manifest, metric_map[ref_metric.get('name')])
Expand All @@ -589,7 +594,11 @@ def _create_metric(name, filter=None, alias=None):
m2 = _create_metric(
numerator.get('name'),
filter=numerator.get('filter'),
alias=numerator.get('alias'))
alias=numerator.get('alias'),
derived_metric=metric.get('name')
)
if m2 is None:
return None
ref_metrics.append(m2)
derived_time_grains = find_derived_time_grains(manifest, metric_map[numerator.get('name')])
if len(time_grains) < len(derived_time_grains):
Expand All @@ -599,7 +608,11 @@ def _create_metric(name, filter=None, alias=None):
m2 = _create_metric(
denominator.get('name'),
filter=denominator.get('filter'),
alias=denominator.get('alias'))
alias=denominator.get('alias'),
derived_metric=metric.get('name')
)
if m2 is None:
return None
ref_metrics.append(m2)
derived_time_grains = find_derived_time_grains(manifest, metric_map[denominator.get('name')])
if len(time_grains) < len(derived_time_grains):
Expand Down

0 comments on commit 48ed186

Please sign in to comment.