Skip to content

Commit

Permalink
fix: simply is_adhoc_metric (#10964)
Browse files Browse the repository at this point in the history
* fix: simply is_adhoc_metric

* address comment
  • Loading branch information
villebro authored Sep 20, 2020
1 parent 557a303 commit 3d8f757
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions superset/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3d8f757

Please sign in to comment.