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

feat(sqllab): Add a configuration option to disable data preview #19104

Merged

Conversation

cccs-Dustin
Copy link
Contributor

@cccs-Dustin cccs-Dustin commented Mar 10, 2022

SUMMARY

This PR is a rebase of the original #14768 PR created by @akedrou. The original modifications made to the code were kept intact, however, to ensure that the feature works on master, I had to make some minor modifications to specific files. I also made some edits/additions based on the feedback that was given on the original PR.


Original PR's Summary:

This PR adds a new per-database configuration option to disable data preview queries in SQL Lab. This setting is exposed in the database API as disable_preview_data. I decided to add the feature to the database API and pass the database as a parameter to addTable rather than adding a database setting into a table API response (the proposed solution in #14726). As a result, the data preview query was moved up to addTable as well. To my eye that looks cleaner since I don't think that previewing data should be a part of "table metadata" anyway.

There is no UI change, though the UX changes when data preview is disabled to not show the data preview pane (or results) when getting table metadata.

NOTE: The original PR mentions that there is no UI change, this is no longer the case as there is now a new checkbox in the "Advanced>SQL Lab" section of a database settings page.


BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

To test that the SQL Lab data preview is disabled when the checkbox is selected

  1. In the database configuration settings, select "Disable SQL Lab data preview queries" under "Advanced>SQL Lab".
  2. In SQL Editor, select the database you have configured, and then any schema or table.
    - Alternately, trigger metadata to load from the editor textbox itself.
  3. Table metadata should load as normal, but no data preview query should run.

To test that the SQL Lab data preview works when the checkbox is not selected

  1. In the database configuration settings, unselect "Disable SQL Lab data preview queries" under "Advanced>SQL Lab".
  2. In SQL Editor, select the database you have configured, and then any schema or table.
    - Alternately, trigger metadata to load from the editor textbox itself.
  3. Table metadata should load as normal, and a data preview query should run.

You can also run the following tests to make sure they still pass after the code modifications:

npm test ./src/components/DatabaseSelector/DatabaseSelector.test.tsx
npm test ./src/SqlLab/actions/sqlLab.test.js
npm test ./src/SqlLab/components/SqlEditor/SqlEditor.test.jsx
npm test ./src/SqlLab/components/SqlEditorLeftBar/SqlEditorLeftBar.test.jsx

tox -e py38 -- tests/integration_tests/core_tests.py
tox -e py38 -- tests/integration_tests/databases/api_tests.py

ADDITIONAL INFORMATION

akedrou and others added 14 commits May 21, 2021 17:18
This setting is per-database in the "extra" JSON data.
…n the PR. The largest change was reversing the flag from 'allows_preview_data' to 'disable_preview_data'. This required changes to a lot of the files, as well as I needed to reverse the expected boolean values on some of the tests
…ring is passed into the parameter instead of a boolean value, it will return False
@cccs-Dustin
Copy link
Contributor Author

Hi @villebro! Would you be able to review this PR when you get the chance? It has all of the modifications you commented on in the original PR.

@codecov
Copy link

codecov bot commented Mar 10, 2022

Codecov Report

Merging #19104 (b5b43d4) into master (cfb967f) will increase coverage by 0.00%.
The diff coverage is 90.90%.

@@           Coverage Diff           @@
##           master   #19104   +/-   ##
=======================================
  Coverage   66.73%   66.74%           
=======================================
  Files        1668     1668           
  Lines       64271    64279    +8     
  Branches     6496     6496           
=======================================
+ Hits        42894    42902    +8     
  Misses      19695    19695           
  Partials     1682     1682           
Flag Coverage Δ
hive 52.65% <83.33%> (+<0.01%) ⬆️
javascript 51.32% <80.00%> (+<0.01%) ⬆️
mysql 81.97% <100.00%> (+<0.01%) ⬆️
postgres 82.01% <100.00%> (+<0.01%) ⬆️
presto 52.50% <83.33%> (+<0.01%) ⬆️
python 82.44% <100.00%> (+<0.01%) ⬆️
sqlite 81.77% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
...d/src/SqlLab/components/AceEditorWrapper/index.tsx 44.82% <ø> (ø)
...frontend/src/SqlLab/components/SqlEditor/index.jsx 50.84% <ø> (ø)
...d/src/SqlLab/components/SqlEditorLeftBar/index.tsx 56.75% <0.00%> (ø)
.../CRUD/data/database/DatabaseModal/ExtraOptions.tsx 83.33% <ø> (ø)
superset/databases/api.py 93.99% <ø> (ø)
superset/databases/schemas.py 98.47% <ø> (ø)
superset/views/core.py 75.85% <ø> (ø)
superset/views/database/mixins.py 81.03% <ø> (ø)
superset-frontend/src/SqlLab/actions/sqlLab.js 60.73% <100.00%> (+0.22%) ⬆️
superset/dashboards/schemas.py 99.41% <100.00%> (+<0.01%) ⬆️
... and 1 more

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 cfb967f...b5b43d4. Read the comment docs.

@cccs-Dustin cccs-Dustin changed the title WIP feat(sqllab): Add a configuration option to disable data preview - Rabase of original PR feat(sqllab): WIP Add a configuration option to disable data preview - Rabase of original PR Mar 10, 2022
@villebro villebro changed the title feat(sqllab): WIP Add a configuration option to disable data preview - Rabase of original PR feat(sqllab): WIP Add a configuration option to disable data preview Mar 15, 2022
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.

Two minor comments

@cccs-Dustin cccs-Dustin changed the title feat(sqllab): WIP Add a configuration option to disable data preview feat(sqllab): Add a configuration option to disable data preview Mar 15, 2022
@cccs-Dustin cccs-Dustin requested a review from villebro March 15, 2022 13:10
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.

Thanks for this awesome improvement @akedrou and @cccs-Dustin , LGTM!

@villebro villebro merged commit 02ef9ca into apache:master Mar 17, 2022
@cccs-Dustin cccs-Dustin deleted the update-configure-data-preview branch March 28, 2022 17:28
villebro pushed a commit that referenced this pull request Apr 3, 2022
@mistercrunch mistercrunch added 🍒 1.5.0 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.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 lts-v1 size/L 🍒 1.5.0 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants