Skip to content

Commit

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

* address comment
  • Loading branch information
villebro committed Sep 20, 2020
1 parent 0feec21 commit 5a608d3
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 @@ -1010,24 +1010,7 @@ def get_example_database() -> "Database":


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 5a608d3

Please sign in to comment.