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: Ensure verbose mapping exists for SQL Lab Query model #23597

Conversation

john-bodley
Copy link
Member

@john-bodley john-bodley commented Apr 5, 2023

SUMMARY

This PR fixes an error when applying post processing for a pivot chart et al. when the underlying datasource is non-materialized, i.e., a superset.models.sql_lab.Query object as opposed to a materialized datasource, i.e., a superset.connectors.base.models.BaseDatasource object.

The underlying issue is that the superset.models.sql_lab.Query.data property did not include the verbose_map field which is present in the superset.connectors.base.models.BaseDatasource.dataproperty, i.e.,

...
  File "<prefix>/superset/charts/post_processing.py", line 352, in apply_post_process
    df.rename(columns=datasource.data["verbose_map"], inplace=True)
KeyError: 'verbose_map'

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

CI and tested locally.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@@ -246,6 +246,7 @@ def data(self) -> Dict[str, Any]:
"database": {"id": self.database_id, "backend": self.database.backend},
"order_by_choices": order_by_choices,
"schema": self.schema,
"verbose_map": {},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Present here for the superset.connectors.base.models.BaseDatasource model.

@john-bodley john-bodley force-pushed the john-bodley--sql-lab-query-verbose-map branch from 44a1f08 to ef92ba2 Compare April 5, 2023 22:44
@john-bodley john-bodley marked this pull request as ready for review April 5, 2023 22:44
@codecov
Copy link

codecov bot commented Apr 5, 2023

Codecov Report

Merging #23597 (c53f60c) into master (56dcf25) will decrease coverage by 0.01%.
The diff coverage is 57.14%.

❗ Current head c53f60c differs from pull request most recent head ef92ba2. Consider uploading reports for the commit ef92ba2 to get more accurate results

@@            Coverage Diff             @@
##           master   #23597      +/-   ##
==========================================
- Coverage   67.72%   67.72%   -0.01%     
==========================================
  Files        1916     1916              
  Lines       74051    74054       +3     
  Branches     8040     8040              
==========================================
+ Hits        50153    50154       +1     
- Misses      21850    21852       +2     
  Partials     2048     2048              
Flag Coverage Δ
hive 52.75% <57.14%> (-0.01%) ⬇️
mysql 78.48% <57.14%> (-0.01%) ⬇️
postgres 78.56% <57.14%> (-0.01%) ⬇️
presto 52.67% <57.14%> (-0.01%) ⬇️
python 82.41% <57.14%> (-0.01%) ⬇️
sqlite 77.07% <57.14%> (-0.01%) ⬇️
unit 52.64% <57.14%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
superset/models/sql_lab.py 75.00% <ø> (ø)
superset/utils/core.py 90.90% <33.33%> (-0.10%) ⬇️
superset/charts/post_processing.py 89.36% <50.00%> (-0.64%) ⬇️
superset/charts/data/api.py 88.88% <100.00%> (+0.06%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for improving type safety.

@john-bodley john-bodley merged commit 83df609 into apache:master Apr 6, 2023
@john-bodley john-bodley deleted the john-bodley--sql-lab-query-verbose-map branch April 6, 2023 18:34
john-bodley added a commit to airbnb/superset-fork that referenced this pull request Apr 6, 2023
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.0.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/S 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants