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] SQL query source #9173

Merged
merged 1 commit into from
Feb 20, 2020

Conversation

john-bodley
Copy link
Member

@john-bodley john-bodley commented Feb 20, 2020

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

This PR makes a couple of updates to the encoding of the query source for SQL queries:

  1. Uses an enum as opposed to a string to int dictionary mapping.
  2. Moves the referrer logic (used for determining dashboard and chart queries) from get_df to get_sqla_engine.

The reason for the later was there were a number of places where get_sqla_engine were being called without a source and it felt that this would be a better place to add the fallback logic if the source wasn't explicitly defined.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TEST PLAN

CI and tested locally.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

REVIEWERS

to: @etr2460 @villebro

@@ -314,6 +314,12 @@ def get_sqla_engine(
params.update(self.get_encrypted_extra())

if DB_CONNECTION_MUTATOR:
if not source and request and request.referrer:
Copy link
Member Author

Choose a reason for hiding this comment

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

This is similar logic to what was defined in get_df however it's been pushed further up the stack. Note we only try to mutate the source if it isn't explicitly defined.

@codecov-io
Copy link

codecov-io commented Feb 20, 2020

Codecov Report

Merging #9173 into master will decrease coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9173      +/-   ##
==========================================
- Coverage   59.16%   59.13%   -0.04%     
==========================================
  Files         372      372              
  Lines       11935    11938       +3     
  Branches     2927     2925       -2     
==========================================
- Hits         7061     7059       -2     
- Misses       4694     4699       +5     
  Partials      180      180
Impacted Files Coverage Δ
...ontend/src/components/ListView/TableCollection.tsx 88.88% <0%> (-3.71%) ⬇️
...frontend/src/views/dashboardList/DashboardList.tsx 69.72% <0%> (-3.43%) ⬇️
...uperset-frontend/src/views/chartList/ChartList.tsx 74.48% <0%> (-0.26%) ⬇️
...et-frontend/src/components/ConfirmStatusChange.tsx 100% <0%> (ø) ⬆️
...rset-frontend/src/components/ListView/ListView.tsx 92.4% <0%> (+0.19%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c1750af...5a4cb9c. Read the comment docs.

Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

lgtm, one nit

superset/utils/core.py Outdated Show resolved Hide resolved
Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

nice 👍

@john-bodley john-bodley merged commit 1415706 into apache:master Feb 20, 2020
@john-bodley john-bodley deleted the john-bodley--fix-sqla-source branch February 20, 2020 19:15
john-bodley added a commit to airbnb/superset-fork that referenced this pull request Feb 20, 2020
(cherry picked from commit 1415706)
john-bodley added a commit to airbnb/superset-fork that referenced this pull request Feb 20, 2020
(cherry picked from commit 1415706)
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.36.0 labels Feb 28, 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/M 🚢 0.36.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants