Skip to content
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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Conversation

sowo
Copy link
Contributor

@sowo sowo commented Apr 24, 2024

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

@sowo sowo changed the title Fix label map fix(contextmenu): uncaught TypeError Apr 24, 2024
@@ -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)
Copy link
Member

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?

Copy link
Contributor Author

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.

@sowo sowo marked this pull request as draft April 25, 2024 11:51
@pull-request-size pull-request-size bot added size/M and removed size/S labels May 3, 2024
@codecov-commenter
Copy link

codecov-commenter commented May 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.82%. Comparing base (76d897e) to head (2a5ff3d).
Report is 1168 commits behind head on master.

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     
Flag Coverage Δ
hive 48.78% <16.66%> (-0.39%) ⬇️
javascript ?
mysql 76.55% <100.00%> (?)
postgres 76.61% <100.00%> (?)
presto 53.31% <83.33%> (-0.50%) ⬇️
python 83.82% <100.00%> (+20.33%) ⬆️
sqlite 76.07% <100.00%> (?)
unit 60.93% <33.33%> (+3.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sowo sowo marked this pull request as ready for review May 7, 2024 18:31
@rusackas
Copy link
Member

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!

@rusackas
Copy link
Member

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.

@sowo
Copy link
Contributor Author

sowo commented Dec 10, 2024 via email

@sowo
Copy link
Contributor Author

sowo commented Dec 11, 2024 via email

@rusackas
Copy link
Member

rusackas commented Dec 11, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants