mirror of https://github.com/apache/superset.git
fix: simply is_adhoc_metric (#10964)
* fix: simply is_adhoc_metric * address comment
This commit is contained in:
parent
557a303cc5
commit
3d8f757ac8
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue