cccs-Dustin opened a new pull request #18946: URL: https://github.com/apache/superset/pull/18946
### SUMMARY <!--- Describe the change below, including rationale and design decisions --> This PR is a rebase of the original https://github.com/apache/superset/pull/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. ---------------------------------------- **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 allows_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 https://github.com/apache/superset/issues/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 <!--- Skip this if not applicable --> N/A ### TESTING INSTRUCTIONS <!--- Required! What steps can be taken to manually verify the changes? --> **To test that the SQL Lab data preview works when the checkbox is selected** 1. In the database configuration settings, select "Allow 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. 4. Table metadata should load as normal, and a data preview query should run. **To test that the SQL Lab data preview is disabled when the checkbox is not selected** 1. In the database configuration settings, unselect "Allow 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. **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 <!--- Check any relevant boxes with "x" --> <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue --> - [x] Has associated issue: https://github.com/apache/superset/issues/14726 - [x] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [x] Introduces new feature or API - [ ] Removes existing feature or API -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
