villebro commented on a change in pull request #16194:
URL: https://github.com/apache/superset/pull/16194#discussion_r687420777
##########
File path: superset/utils/core.py
##########
@@ -1273,7 +1280,33 @@ def is_adhoc_metric(metric: Metric) -> bool:
def get_metric_name(metric: Metric) -> str:
- return metric["label"] if is_adhoc_metric(metric) else metric # type:
ignore
+ """
+ Extract label from metric
+
+ :param metric: object to extract label from
+ :return: String representation of metric
+ :raises ValueError: if metric object is invalid
+ """
+ if is_adhoc_metric(metric):
Review comment:
Amazing, I didn't know these were forthcoming! 🚀 Super cool, I'll
implement right away. Btw, the functionality surrounding the `Metric` type is
is pretty bad shape (e.g. `QueryObject` assumes the presence of a metric type
consisting of a dict with only the property `label` that doesn't have a type
definition, some geospatial viz plugins in `viz.py` apparently rely on
`get_metric_name` to return `None` and `int` values in some cases), so I
decided to break up the refactor into multiple smaller PRs to keep them
manageable. So I will follow-up with some additional cleanup avoid this
becoming XXXL.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]