fix: simply is_adhoc_metric (#10964)

* fix: simply is_adhoc_metric

* address comment
This commit is contained in:
Ville Brofeldt 2020-09-20 13:22:55 +03:00 committed by GitHub
parent 557a303cc5
commit 3d8f757ac8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 18 deletions

View File

@ -1040,24 +1040,7 @@ def backend() -> str:
def is_adhoc_metric(metric: Metric) -> bool:
if not isinstance(metric, dict):
return False
metric = cast(Dict[str, Any], metric)
return bool(
(
(
metric.get("expressionType") == AdhocMetricExpressionType.SIMPLE
and metric.get("column")
and cast(Dict[str, Any], metric["column"]).get("column_name")
and metric.get("aggregate")
)
or (
metric.get("expressionType") == AdhocMetricExpressionType.SQL
and metric.get("sqlExpression")
)
)
and metric.get("label")
)
return isinstance(metric, dict)
def get_metric_name(metric: Metric) -> str: