-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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 #14768
Conversation
This setting is per-database in the "extra" JSON data.
Thanks for the enhancement @akedrou.. I'm running tests now and added some reviewers. |
@villebro This is the PR I was hoping we could get merged! :) |
@villebro No problem! I figured it just slipped by and I didn't have the dedication to keep nagging - I should have some time to rebase within the next few days. Thanks for coming back to the PR! |
… sure the code is compatible with master
…kboxes and tooltips but there are now 8
…kboxes and tooltips but there are now 8
Codecov Report
@@ Coverage Diff @@
## master #14768 +/- ##
==========================================
- Coverage 66.35% 66.04% -0.31%
==========================================
Files 1640 1643 +3
Lines 63486 65575 +2089
Branches 6409 6503 +94
==========================================
+ Hits 42124 43309 +1185
- Misses 19702 20574 +872
- Partials 1660 1692 +32
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great improvement! Something I've often been annoyed by. Some comments. Also, it seems there's currently a regression on master that breaks fetching table names (see #19008), so that probably needs to be fixed before we can properly test this
}); | ||
|
||
it('updates and runs data preview query when configured', () => { | ||
expect.assertions(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be
expect.assertions(2); | |
expect.assertions(5); |
expect(fetchMock.calls(updateTableSchemaEndpoint)).toHaveLength(1); | ||
expect(fetchMock.calls(getTableMetadataEndpoint)).toHaveLength(1); | ||
expect(fetchMock.calls(getExtraTableMetadataEndpoint)).toHaveLength( | ||
1, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..and these lines should not be removed (I tested locally, and the test passes with these changes)
<StyledInputContainer> | ||
<div className="input-container"> | ||
<IndeterminateCheckbox | ||
id="allows_preview_data" | ||
indeterminate={false} | ||
checked={!!db?.extra_json?.allows_preview_data} | ||
onChange={onExtraInputChange} | ||
labelText={t('Allow SQL Lab data preview queries')} | ||
/> | ||
<InfoTooltip | ||
tooltip={t( | ||
'The allows_preview_data field is a boolean specifying whether or not data ' + | ||
'preview queries will be run when fetching table metadata in SQL Lab.', | ||
)} | ||
/> | ||
</div> | ||
</StyledInputContainer> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we may need to reverse this flag to disable_preview_data
, as otherwise this will disable data preview for existing databases (breaking change)
FYI @akedrou - @cccs-Dustin was kind enough to rebase this PR (I pushed the changes here). It still appears to need some lint cleanup + I added a few review comments. Let me know if you need help finishing this PR! |
Closing in favor of #19104 which finished this work |
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
preview_data
. I decided to add the feature to the database API and pass the database as a parameter toaddTable
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 toaddTable
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.
TESTING INSTRUCTIONS
"preview_data": false
to the "Extra" JSON object.preview_data
is true (or the key does not exist), a data preview query should run when selecting a table from the dropdown or triggering metadata to be loaded from the editor.ADDITIONAL INFORMATION