-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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 60.48% 83.82% +23.33%
===========================================
Files 1931 537 -1394
Lines 76236 39006 -37230
Branches 8568 0 -8568
===========================================
- Hits 46114 32697 -13417
+ Misses 28017 6309 -21708
+ Partials 2105 0 -2105
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Hey @sowo - sorry this seems to have slipped through the cracks, but if you're able to rebase this to resolve conflicts, I think we can get some more eyes on it and get it merged. Thanks! |
Thanks for the quick rebase! Looks like there are some test failures on CI, but I'm not sure if they're related to the change or not. |
as far as I can tell, all test failures complain about missing strftime.
(either "AttributeError: 'numpy.float64' object has no attribute
'strftime'" or "AttributeError: 'str' object has no attribute 'strftime'").
I don't think the changes in PR are causing those.
…On Tue, Dec 10, 2024 at 10:06 PM Evan Rusackas ***@***.***> wrote:
Thanks for the quick rebase! Looks like there are some test failures on
CI, but I'm not sure if they're related to the change or not.
—
Reply to this email directly, view it on GitHub
<#28203 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAVDI5L5ZIMNB7ULZLOUWQD2E5JWPAVCNFSM6AAAAABTL2O7FGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMZSHA4TCOBYGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
turns out there was an issue in query_context_processor. Tests are passing
now.
On Tue, Dec 10, 2024 at 10:12 PM Wolfgang Sommerer <
***@***.***> wrote:
… as far as I can tell, all test failures complain about missing strftime.
(either "AttributeError: 'numpy.float64' object has no attribute
'strftime'" or "AttributeError: 'str' object has no attribute 'strftime'").
I don't think the changes in PR are causing those.
On Tue, Dec 10, 2024 at 10:06 PM Evan Rusackas ***@***.***>
wrote:
> Thanks for the quick rebase! Looks like there are some test failures on
> CI, but I'm not sure if they're related to the change or not.
>
> —
> Reply to this email directly, view it on GitHub
> <#28203 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAVDI5L5ZIMNB7ULZLOUWQD2E5JWPAVCNFSM6AAAAABTL2O7FGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMZSHA4TCOBYGA>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
Thanks for getting the tests passing! I will ping @villebro as a more capable reviewer than myself when it comes to query context, but I suspect if we don't merge it as-is, the reason would be for need of additional test coverage around handling of verbose maps, ad hoc metrics, ad hoc columns, and error handling. |
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