New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(contextmenu): uncaught TypeError #28203
base: master
Are you sure you want to change the base?
Conversation
superset/common/query_object.py
Outdated
@@ -257,7 +257,7 @@ def _move_deprecated_extra_fields(self, kwargs: dict[str, Any]) -> None: | |||
@property | |||
def metric_names(self) -> list[str]: | |||
"""Return metrics names (labels), coerce adhoc metrics to strings.""" | |||
return get_metric_names(self.metrics or []) | |||
return get_metric_names(self.metrics or [], self.datasource.verbose_map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add a small unit test to verify that metric_names will always return properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hughhhh I've added a unit test and some sanity checking. Not sure if the implementation of those checks (https://github.com/sowo/superset/blob/bd0015426aab9ed949259454e36572473b927c39/superset/common/query_context_processor.py#L187 and https://github.com/sowo/superset/blob/bd0015426aab9ed949259454e36572473b927c39/superset/common/query_context_processor.py#L197) is optimal or if there is a better way to handle AdhocColumns and AdhocMetrics. Please advise.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #28203 +/- ##
===========================================
+ Coverage 67.42% 83.16% +15.74%
===========================================
Files 1923 521 -1402
Lines 75591 37187 -38404
Branches 8443 0 -8443
===========================================
- Hits 50967 30928 -20039
+ Misses 22566 6259 -16307
+ Partials 2058 0 -2058
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
SUMMARY
This PR resolves a uncaught TypeError in MixedTimeseries charts with saved metrics.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before
Screencast from 04-24-2024 05:16:25 PM.webm
After
Screencast from 04-24-2024 08:09:58 PM.webm
TESTING INSTRUCTIONS
Create a MixedTimeseries chart with using saved metrics. Without the PR, the context menu (right click) will throw an uncaught TypeError exception. With the PR, the context menu works as expected.
ADDITIONAL INFORMATION