You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/11/21 08:25:31 UTC
[GitHub] [superset] villebro commented on a diff in pull request #22147: fix: Unhandled exception Str Column Type
villebro commented on code in PR #22147:
URL: https://github.com/apache/superset/pull/22147#discussion_r1027699625
##########
superset/connectors/base/models.py:
##########
@@ -312,9 +312,9 @@ def data_for_slices( # pylint: disable=too-many-locals
for metric in utils.get_iterable(form_data.get(metric_param) or []):
metric_names.add(utils.get_metric_name(metric))
if utils.is_adhoc_metric(metric):
- column_names.add(
- (metric.get("column") or {}).get("column_name")
- )
+ column = metric.get("column") or {}
+ if hasattr(column, "get") and "column_name" in column:
+ column_names.add(column.get("column_name"))
Review Comment:
Looking at the `AdhocMetric` class, it appears `column` is `Optional[AdhocMetricColumn]`, which in turn is a `TypedDict`. So `hasattr(column, "get")` will always be true based on line 315. So I believe this can be simplified to
```suggestion
if column_name := column.get("column_name"):
column_names.add(column_name)
```
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org