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 Lab QuerySource via referrer #22172

Merged
merged 1 commit into from
Nov 21, 2022

Conversation

john-bodley
Copy link
Member

SUMMARY

At Airbnb we've noticed in the logs (see attached) that the QuerySource is undefined which occurs the referrer is of the form .../superset/sqllab i.e., without the trailing /.

Screen Shot 2022-11-19 at 1 19 59 AM

Grokking through the code there are a number of examples where the trailing / isn't provided, hence it seems prudent to relax the requirement that the trailing / is required to match queries originating from SQL Lab.

$ git grep "/sqllab?"
docs/docs/installation/sql-templating.mdx:  coworker in Spain the following SQL Lab URL `www.example.com/superset/sqllab?countrycode=ES`
docs/docs/installation/sql-templating.mdx:  and your coworker in the USA the following SQL Lab URL `www.example.com/superset/sqllab?countrycode=US`
superset-frontend/src/SqlLab/components/QueryTable/index.tsx:  const url = `/superset/sqllab?queryId=${id}`;
superset-frontend/src/views/CRUD/data/query/QueryList.tsx:            <a href={`/superset/sqllab?queryId=${id}`}>
superset-frontend/src/views/CRUD/data/query/QueryList.tsx:            window.location.assign(`/superset/sqllab?queryId=${id}`)
superset-frontend/src/views/CRUD/data/savedquery/SavedQueryList.tsx:    window.open(`${window.location.origin}/superset/sqllab?new=true`);
superset-frontend/src/views/CRUD/data/savedquery/SavedQueryList.tsx:    window.open(`${window.location.origin}/superset/sqllab?savedQueryId=${id}`);
superset-frontend/src/views/CRUD/data/savedquery/SavedQueryList.tsx:          `${window.location.origin}/superset/sqllab?savedQueryId=${id}`,
superset-frontend/src/views/CRUD/hooks.ts:      `${window.location.origin}/superset/sqllab?savedQueryId=${id}`,
superset-frontend/src/views/CRUD/welcome/ActivityTable.tsx:  if ('sql' in entity) return `/superset/sqllab?savedQueryId=${entity.id}`;
superset-frontend/src/views/CRUD/welcome/EmptyState.tsx:    [WelcomeTable.SavedQueries]: '/superset/sqllab?new=true',
superset-frontend/src/views/CRUD/welcome/SavedQueries.tsx:            window.location.href = `/superset/sqllab?savedQueryId=${query.id}`;
superset-frontend/src/views/CRUD/welcome/SavedQueries.tsx:              window.location.href = '/superset/sqllab?new=true';
superset-frontend/src/views/CRUD/welcome/SavedQueries.tsx:                window.location.href = `/superset/sqllab?savedQueryId=${q.id}`;
superset-frontend/src/views/CRUD/welcome/SavedQueries.tsx:                url={`/superset/sqllab?savedQueryId=${q.id}`}
superset-frontend/src/views/components/Menu.test.tsx:    url: '/superset/sqllab?new=true',
superset-frontend/src/views/components/RightMenu.test.tsx:    url: '/superset/sqllab?new=true',
superset-frontend/src/views/components/RightMenu.tsx:      url: '/superset/sqllab?new=true',
superset/jinja_context.py:        `?foo=bar`, as in `{domain}/superset/sqllab?foo=bar`. Then if your query is
superset/models/sql_lab.py:            <a href="/superset/sqllab?savedQueryId={self.id}">
superset/models/sql_lab.py:        return "/superset/sqllab?savedQueryId={0}".format(self.id)

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

CI.

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

@john-bodley john-bodley requested review from etr2460, villebro and ktmud and removed request for etr2460 November 19, 2022 09:22
@john-bodley john-bodley marked this pull request as ready for review November 19, 2022 09:22
@codecov
Copy link

codecov bot commented Nov 19, 2022

Codecov Report

Merging #22172 (4439524) into master (7e54b88) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master   #22172      +/-   ##
==========================================
- Coverage   67.00%   67.00%   -0.01%     
==========================================
  Files        1835     1835              
  Lines       69964    69964              
  Branches     7588     7588              
==========================================
- Hits        46879    46878       -1     
- Misses      21119    21120       +1     
  Partials     1966     1966              
Flag Coverage Δ
hive 52.61% <0.00%> (ø)
javascript 53.81% <ø> (ø)
mysql 78.14% <0.00%> (ø)
postgres 78.20% <0.00%> (-0.01%) ⬇️
presto 52.50% <0.00%> (ø)
python 81.39% <0.00%> (-0.01%) ⬇️
sqlite 76.66% <0.00%> (ø)
unit 50.90% <0.00%> (ø)

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

Impacted Files Coverage Δ
superset/models/core.py 90.50% <0.00%> (ø)
superset/views/core.py 76.11% <0.00%> (-0.08%) ⬇️

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

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.

LGTM

@john-bodley john-bodley merged commit f40e6d1 into master Nov 21, 2022
john-bodley added a commit to airbnb/superset-fork that referenced this pull request Nov 21, 2022
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 2024
@mistercrunch mistercrunch deleted the john-bodley--fix-sql-lab-query-source branch March 26, 2024 16:14
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/XS 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants