From 6cc44c914b04cbe349f8cf4ee0504879ac72d77d Mon Sep 17 00:00:00 2001 From: Tom Skinner Date: Fri, 21 May 2021 17:18:55 -0700 Subject: [PATCH 01/14] feat(sqllab) Add a configuration option to disable data preview This setting is per-database in the "extra" JSON data. --- .../javascripts/sqllab/actions/sqlLab_spec.js | 44 +++++++++++++++---- .../src/SqlLab/actions/sqlLab.js | 40 ++++++++++------- .../SqlLab/components/AceEditorWrapper.tsx | 4 +- .../src/SqlLab/components/SqlEditor.jsx | 1 + .../SqlLab/components/SqlEditorLeftBar.jsx | 14 +++++- .../database/DatabaseModal/ExtraOptions.tsx | 6 +++ superset/databases/api.py | 1 + superset/databases/schemas.py | 6 ++- superset/models/core.py | 5 +++ superset/views/core.py | 1 + tests/databases/api_tests.py | 1 + 11 files changed, 92 insertions(+), 31 deletions(-) diff --git a/superset-frontend/spec/javascripts/sqllab/actions/sqlLab_spec.js b/superset-frontend/spec/javascripts/sqllab/actions/sqlLab_spec.js index 44e468cf57e81..853dacd3ac032 100644 --- a/superset-frontend/spec/javascripts/sqllab/actions/sqlLab_spec.js +++ b/superset-frontend/spec/javascripts/sqllab/actions/sqlLab_spec.js @@ -683,37 +683,63 @@ describe('async actions', () => { it('updates the table schema state in the backend', () => { expect.assertions(5); + const database = { preview_data: false }; + const tableName = 'table'; + const schemaName = 'schema'; + const store = mockStore({}); + const expectedActionTypes = [ + actions.MERGE_TABLE, // addTable + actions.MERGE_TABLE, // getTableMetadata + actions.MERGE_TABLE, // getTableExtendedMetadata + actions.MERGE_TABLE, // addTable + ]; + return store + .dispatch(actions.addTable(query, database, tableName, schemaName)) + .then(() => { + expect(store.getActions().map(a => a.type)).toEqual( + expectedActionTypes, + ); + expect(fetchMock.calls(updateTableSchemaEndpoint)).toHaveLength(1); + expect(fetchMock.calls(getTableMetadataEndpoint)).toHaveLength(1); + expect(fetchMock.calls(getExtraTableMetadataEndpoint)).toHaveLength( + 1, + ); + + // tab state is not updated, since no query was run + expect(fetchMock.calls(updateTabStateEndpoint)).toHaveLength(0); + }); + }); + it('updates and runs data preview query when configured', () => { + expect.assertions(2); + const results = { data: mockBigNumber, - query: { sqlEditorId: 'null' }, + query: { sqlEditorId: 'null', dbId: 1 }, query_id: 'efgh', }; fetchMock.post(runQueryEndpoint, JSON.stringify(results), { overwriteRoutes: true, }); + const database = { preview_data: true, id: 1 }; const tableName = 'table'; const schemaName = 'schema'; const store = mockStore({}); const expectedActionTypes = [ actions.MERGE_TABLE, // addTable actions.MERGE_TABLE, // getTableMetadata - actions.START_QUERY, // runQuery (data preview) actions.MERGE_TABLE, // getTableExtendedMetadata - actions.QUERY_SUCCESS, // querySuccess + actions.MERGE_TABLE, // addTable (data preview) + actions.START_QUERY, // runQuery (data preview) actions.MERGE_TABLE, // addTable + actions.QUERY_SUCCESS, // querySuccess ]; return store - .dispatch(actions.addTable(query, tableName, schemaName)) + .dispatch(actions.addTable(query, database, tableName, schemaName)) .then(() => { expect(store.getActions().map(a => a.type)).toEqual( expectedActionTypes, ); - expect(fetchMock.calls(updateTableSchemaEndpoint)).toHaveLength(1); - expect(fetchMock.calls(getTableMetadataEndpoint)).toHaveLength(1); - expect(fetchMock.calls(getExtraTableMetadataEndpoint)).toHaveLength( - 1, - ); // tab state is not updated, since the query is a data preview expect(fetchMock.calls(updateTabStateEndpoint)).toHaveLength(0); diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js index 8124907a31329..7936ba5fe6939 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.js @@ -991,28 +991,13 @@ function getTableMetadata(table, query, dispatch) { ), }) .then(({ json }) => { - const dataPreviewQuery = { - id: shortid.generate(), - dbId: query.dbId, - sql: json.selectStar, - tableName: table.name, - sqlEditorId: null, - tab: '', - runAsync: false, - ctas: false, - isDataPreview: true, - }; const newTable = { ...table, ...json, expanded: true, isMetadataLoading: false, - dataPreviewQueryId: dataPreviewQuery.id, }; - Promise.all([ - dispatch(mergeTable(newTable, dataPreviewQuery)), // Merge table to tables in state - dispatch(runQuery(dataPreviewQuery)), // Run query to get preview data for table - ]); + dispatch(mergeTable(newTable)); // Merge table to tables in state return newTable; }) .catch(() => @@ -1055,7 +1040,7 @@ function getTableExtendedMetadata(table, query, dispatch) { ); } -export function addTable(query, tableName, schemaName) { +export function addTable(query, database, tableName, schemaName) { return function (dispatch) { const table = { dbId: query.dbId, @@ -1083,6 +1068,27 @@ export function addTable(query, tableName, schemaName) { }) : Promise.resolve({ json: { id: shortid.generate() } }); + if (database.preview_data && database.id == query.dbId) { + const dataPreviewQuery = { + id: shortid.generate(), + dbId: query.dbId, + sql: newTable.selectStar, + tableName: table.name, + sqlEditorId: null, + tab: '', + runAsync: database.allow_run_async, + ctas: false, + isDataPreview: true, + }; + Promise.all([ + dispatch(mergeTable({ + ...newTable, + dataPreviewQueryId: dataPreviewQuery.id, + }, dataPreviewQuery)), + dispatch(runQuery(dataPreviewQuery)) + ]); + } + return sync .then(({ json: resultJson }) => dispatch(mergeTable({ ...table, id: resultJson.id })), diff --git a/superset-frontend/src/SqlLab/components/AceEditorWrapper.tsx b/superset-frontend/src/SqlLab/components/AceEditorWrapper.tsx index 3c33f4c362419..da63ee52401a7 100644 --- a/superset-frontend/src/SqlLab/components/AceEditorWrapper.tsx +++ b/superset-frontend/src/SqlLab/components/AceEditorWrapper.tsx @@ -42,11 +42,12 @@ interface Props { actions: { queryEditorSetSelectedText: (edit: any, text: null | string) => void; queryEditorSetFunctionNames: (queryEditor: object, dbId: number) => void; - addTable: (queryEditor: any, value: any, schema: any) => void; + addTable: (queryEditor: any, database: any, value: any, schema: any) => void; }; autocomplete: boolean; onBlur: (sql: string) => void; sql: string; + database: any; schemas: any[]; tables: any[]; functionNames: string[]; @@ -200,6 +201,7 @@ class AceEditorWrapper extends React.PureComponent { if (data.meta === 'table') { this.props.actions.addTable( this.props.queryEditor, + this.props.database, data.value, this.props.queryEditor.schema, ); diff --git a/superset-frontend/src/SqlLab/components/SqlEditor.jsx b/superset-frontend/src/SqlLab/components/SqlEditor.jsx index 61efad9bfa6a1..c32ca2ec1f2f8 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditor.jsx +++ b/superset-frontend/src/SqlLab/components/SqlEditor.jsx @@ -467,6 +467,7 @@ class SqlEditor extends React.PureComponent { onChange={this.onSqlChanged} queryEditor={this.props.queryEditor} sql={this.props.queryEditor.sql} + database={this.props.database} schemas={this.props.queryEditor.schemaOptions} tables={this.props.queryEditor.tableOptions} functionNames={this.props.queryEditor.functionNames} diff --git a/superset-frontend/src/SqlLab/components/SqlEditorLeftBar.jsx b/superset-frontend/src/SqlLab/components/SqlEditorLeftBar.jsx index 59af1d345da1e..2786146c6bcf6 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditorLeftBar.jsx +++ b/superset-frontend/src/SqlLab/components/SqlEditorLeftBar.jsx @@ -89,7 +89,12 @@ export default class SqlEditorLeftBar extends React.PureComponent { } onTableChange(tableName, schemaName) { - this.props.actions.addTable(this.props.queryEditor, tableName, schemaName); + this.props.actions.addTable( + this.props.queryEditor, + this.props.database, + tableName, + schemaName, + ); } onToggleTable(tables) { @@ -131,7 +136,12 @@ export default class SqlEditorLeftBar extends React.PureComponent { const schemaName = tableOpt.value.schema; const tableName = tableOpt.value.table; this.props.actions.queryEditorSetSchema(this.props.queryEditor, schemaName); - this.props.actions.addTable(this.props.queryEditor, tableName, schemaName); + this.props.actions.addTable( + this.props.queryEditor, + this.props.database, + tableName, + schemaName, + ); } render() { diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx index 8f005f9411ea2..29b3db27e3adc 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx @@ -370,6 +370,12 @@ const ExtraOptions = ({ 'or not the Explore button in SQL Lab results is shown.', )} +
+ {t( + '6. The preview_data field is a boolean specifying whether or not data ' + + 'preview queries will be run when fetching table metadata in SQL Lab.', + )} +
diff --git a/superset/databases/api.py b/superset/databases/api.py index 3f506e0ed5649..4bedd339c7547 100644 --- a/superset/databases/api.py +++ b/superset/databases/api.py @@ -138,6 +138,7 @@ class DatabaseRestApi(BaseSupersetModelRestApi): "expose_in_sqllab", "force_ctas_schema", "id", + "preview_data", ] add_columns = [ "database_name", diff --git a/superset/databases/schemas.py b/superset/databases/schemas.py index a23659fc0fbf8..462864f6cfdbb 100644 --- a/superset/databases/schemas.py +++ b/superset/databases/schemas.py @@ -114,10 +114,12 @@ '["public", "csv_upload"]**. ' "If database flavor does not support schema or any schema is allowed " "to be accessed, just leave the list empty
" - "4. the ``version`` field is a string specifying the this db's version. " + "4. The ``version`` field is a string specifying the this db's version. " "This should be used with Presto DBs so that the syntax is correct
" "5. The ``allows_virtual_table_explore`` field is a boolean specifying " - "whether or not the Explore button in SQL Lab results is shown.", + "whether or not the Explore button in SQL Lab results is shown.
" + "6. The ``preview_data`` field is a boolean specifying whether or not data " + "preview queries will be run when fetching table metadata in SQL Lab.", True, ) get_export_ids_schema = {"type": "array", "items": {"type": "integer"}} diff --git a/superset/models/core.py b/superset/models/core.py index 1868af6c59e09..432e5a70f9497 100755 --- a/superset/models/core.py +++ b/superset/models/core.py @@ -205,6 +205,10 @@ def allows_virtual_table_explore(self) -> bool: return bool(extra.get("allows_virtual_table_explore", True)) + @property + def preview_data(self) -> bool: + return bool(self.get_extra().get("preview_data", True)) + @property def explore_database_id(self) -> int: return self.get_extra().get("explore_database_id", self.id) @@ -222,6 +226,7 @@ def data(self) -> Dict[str, Any]: "allows_virtual_table_explore": self.allows_virtual_table_explore, "explore_database_id": self.explore_database_id, "parameters": self.parameters, + "preview_data": self.preview_data, } @property diff --git a/superset/views/core.py b/superset/views/core.py index 622b1170a7bef..5d688e2bd4ff5 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -158,6 +158,7 @@ "expose_in_sqllab", "force_ctas_schema", "id", + "preview_data", ] DATASOURCE_MISSING_ERR = __("The data source seems to have been deleted") diff --git a/tests/databases/api_tests.py b/tests/databases/api_tests.py index 7f53c579db3cc..c7d9460d5dda6 100644 --- a/tests/databases/api_tests.py +++ b/tests/databases/api_tests.py @@ -168,6 +168,7 @@ def test_get_items(self): "expose_in_sqllab", "force_ctas_schema", "id", + "preview_data", ] self.assertGreater(response["count"], 0) self.assertEqual(list(response["result"][0].keys()), expected_columns) From ad29be68be9700f8c8e404b57ac96ca892529699 Mon Sep 17 00:00:00 2001 From: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com> Date: Thu, 24 Feb 2022 15:01:51 -0500 Subject: [PATCH 02/14] Added in modifications to allow for the old PR feature to be compatible with master --- docs/static/resources/openapi.json | 14 ++++-- .../src/SqlLab/actions/sqlLab.js | 15 ++++--- .../src/SqlLab/actions/sqlLab.test.js | 45 +++++++++++++++---- .../components/AceEditorWrapper/index.tsx | 9 +++- .../src/SqlLab/components/SqlEditor/index.jsx | 1 + .../components/SqlEditorLeftBar/index.tsx | 4 +- .../DatabaseSelector.test.tsx | 4 ++ .../database/DatabaseModal/ExtraOptions.tsx | 19 +++++++- .../src/views/CRUD/data/database/types.ts | 1 + superset/dashboards/schemas.py | 1 + superset/databases/api.py | 2 +- superset/databases/schemas.py | 2 +- superset/views/core.py | 2 +- superset/views/database/mixins.py | 4 +- tests/integration_tests/core_tests.py | 23 ++++++++++ .../integration_tests/databases/api_tests.py | 2 + 16 files changed, 122 insertions(+), 26 deletions(-) diff --git a/docs/static/resources/openapi.json b/docs/static/resources/openapi.json index 1d65671bf3854..de0439dc70aa1 100644 --- a/docs/static/resources/openapi.json +++ b/docs/static/resources/openapi.json @@ -2252,6 +2252,9 @@ "allows_virtual_table_explore": { "type": "boolean" }, + "allows_preview_data": { + "type": "boolean" + }, "backend": { "type": "string" }, @@ -2476,6 +2479,9 @@ "allows_virtual_table_explore": { "readOnly": true }, + "allows_preview_data": { + "readOnly": true + }, "backend": { "readOnly": true }, @@ -2575,7 +2581,7 @@ "type": "boolean" }, "extra": { - "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown.

", + "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. 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.

", "type": "string" }, "force_ctas_schema": { @@ -2667,7 +2673,7 @@ "type": "boolean" }, "extra": { - "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown.

", + "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. 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.

", "type": "string" }, "force_ctas_schema": { @@ -2724,7 +2730,7 @@ "type": "string" }, "extra": { - "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown.

", + "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. 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.

", "type": "string" }, "impersonate_user": { @@ -2772,7 +2778,7 @@ "type": "string" }, "extra": { - "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown.

", + "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. 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.

", "type": "string" }, "impersonate_user": { diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js index 282a65efcaa5e..fa7639b4223d5 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.js @@ -1108,11 +1108,16 @@ export function addTable(query, database, tableName, schemaName) { isDataPreview: true, }; Promise.all([ - dispatch(mergeTable({ - ...newTable, - dataPreviewQueryId: dataPreviewQuery.id, - }, dataPreviewQuery)), - dispatch(runQuery(dataPreviewQuery)) + dispatch( + mergeTable( + { + ...newTable, + dataPreviewQueryId: dataPreviewQuery.id, + }, + dataPreviewQuery, + ), + ), + dispatch(runQuery(dataPreviewQuery)), ]); } diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.test.js b/superset-frontend/src/SqlLab/actions/sqlLab.test.js index 7e1326336f351..eee65cea73e75 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.test.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.test.js @@ -727,37 +727,64 @@ describe('async actions', () => { it('updates the table schema state in the backend', () => { expect.assertions(5); + const database = { allows_preview_data: false }; + const tableName = 'table'; + const schemaName = 'schema'; + const store = mockStore({}); + const expectedActionTypes = [ + actions.MERGE_TABLE, // addTable + actions.MERGE_TABLE, // getTableMetadata + actions.MERGE_TABLE, // getTableExtendedMetadata + actions.MERGE_TABLE, // addTable + ]; + return store + .dispatch(actions.addTable(query, database, tableName, schemaName)) + .then(() => { + expect(store.getActions().map(a => a.type)).toEqual( + expectedActionTypes, + ); + expect(fetchMock.calls(updateTableSchemaEndpoint)).toHaveLength(1); + expect(fetchMock.calls(getTableMetadataEndpoint)).toHaveLength(1); + expect(fetchMock.calls(getExtraTableMetadataEndpoint)).toHaveLength( + 1, + ); + + // tab state is not updated, since no query was run + expect(fetchMock.calls(updateTabStateEndpoint)).toHaveLength(0); + }); + }); + + it('updates and runs data preview query when configured', () => { + expect.assertions(2); + const results = { data: mockBigNumber, - query: { sqlEditorId: 'null' }, + query: { sqlEditorId: 'null', dbId: 1 }, query_id: 'efgh', }; fetchMock.post(runQueryEndpoint, JSON.stringify(results), { overwriteRoutes: true, }); + const database = { allows_preview_data: true, id: 1 }; const tableName = 'table'; const schemaName = 'schema'; const store = mockStore({}); const expectedActionTypes = [ actions.MERGE_TABLE, // addTable actions.MERGE_TABLE, // getTableMetadata - actions.START_QUERY, // runQuery (data preview) actions.MERGE_TABLE, // getTableExtendedMetadata - actions.QUERY_SUCCESS, // querySuccess + actions.MERGE_TABLE, // addTable (data preview) + actions.START_QUERY, // runQuery (data preview) actions.MERGE_TABLE, // addTable + actions.QUERY_SUCCESS, // querySuccess ]; return store - .dispatch(actions.addTable(query, tableName, schemaName)) + .dispatch(actions.addTable(query, database, tableName, schemaName)) .then(() => { expect(store.getActions().map(a => a.type)).toEqual( expectedActionTypes, ); - expect(fetchMock.calls(updateTableSchemaEndpoint)).toHaveLength(1); - expect(fetchMock.calls(getTableMetadataEndpoint)).toHaveLength(1); - expect(fetchMock.calls(getExtraTableMetadataEndpoint)).toHaveLength( - 1, - ); // tab state is not updated, since the query is a data preview expect(fetchMock.calls(updateTabStateEndpoint)).toHaveLength(0); diff --git a/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx b/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx index 8f8e02d227607..d5ec68859c74f 100644 --- a/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx +++ b/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx @@ -43,11 +43,17 @@ interface Props { actions: { queryEditorSetSelectedText: (edit: any, text: null | string) => void; queryEditorSetFunctionNames: (queryEditor: object, dbId: number) => void; - addTable: (queryEditor: any, value: any, schema: any) => void; + addTable: ( + queryEditor: any, + database: any, + value: any, + schema: any, + ) => void; }; autocomplete: boolean; onBlur: (sql: string) => void; sql: string; + database: any; schemas: any[]; tables: any[]; functionNames: string[]; @@ -203,6 +209,7 @@ class AceEditorWrapper extends React.PureComponent { if (data.meta === 'table') { this.props.actions.addTable( this.props.queryEditor, + this.props.database, data.value, this.props.queryEditor.schema, ); diff --git a/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx b/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx index 22711fb88d9e8..2fb2ad82832d6 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx +++ b/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx @@ -504,6 +504,7 @@ class SqlEditor extends React.PureComponent { onChange={this.onSqlChanged} queryEditor={this.props.queryEditor} sql={this.props.queryEditor.sql} + database={this.props.database} schemas={this.props.queryEditor.schemaOptions} tables={this.props.queryEditor.tableOptions} functionNames={this.props.queryEditor.functionNames} diff --git a/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx b/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx index 4ea89ad477ef1..1d4536521b960 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx +++ b/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx @@ -36,7 +36,7 @@ interface actionsTypes { queryEditorSetFunctionNames: (queryEditor: QueryEditor, dbId: number) => void; collapseTable: (table: Table) => void; expandTable: (table: Table) => void; - addTable: (queryEditor: any, value: any, schema: any) => void; + addTable: (queryEditor: any, database: any, value: any, schema: any) => void; setDatabases: (arg0: any) => {}; addDangerToast: (msg: string) => void; queryEditorSetSchema: (schema?: string) => void; @@ -93,7 +93,7 @@ export default function SqlEditorLeftBar({ const onTableChange = (tableName: string, schemaName: string) => { if (tableName && schemaName) { - actions.addTable(queryEditor, tableName, schemaName); + actions.addTable(queryEditor, database, tableName, schemaName); } }; diff --git a/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx b/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx index d8d4e23eb1651..f802aad5faa93 100644 --- a/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx +++ b/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx @@ -76,6 +76,7 @@ beforeEach(() => { allows_cost_estimate: 'Allows Cost Estimate', allows_subquery: 'Allows Subquery', allows_virtual_table_explore: 'Allows Virtual Table Explore', + allows_preview_data: 'Allows SQL Lab Data Preview', backend: 'Backend', changed_on: 'Changed On', changed_on_delta_humanized: 'Changed On Delta Humanized', @@ -97,6 +98,7 @@ beforeEach(() => { 'allows_cost_estimate', 'allows_subquery', 'allows_virtual_table_explore', + 'allows_preview_data', 'backend', 'changed_on', 'changed_on_delta_humanized', @@ -130,6 +132,7 @@ beforeEach(() => { allows_cost_estimate: null, allows_subquery: true, allows_virtual_table_explore: true, + allows_preview_data: true, backend: 'postgresql', changed_on: '2021-03-09T19:02:07.141095', changed_on_delta_humanized: 'a day ago', @@ -150,6 +153,7 @@ beforeEach(() => { allows_cost_estimate: null, allows_subquery: true, allows_virtual_table_explore: true, + allows_preview_data: true, backend: 'mysql', changed_on: '2021-03-09T19:02:07.141095', changed_on_delta_humanized: 'a day ago', diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx index fd810e3294efc..1ebb2ec74034c 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx @@ -182,7 +182,7 @@ const ExtraOptions = ({ /> - +
+ +
+ + +
+
diff --git a/superset-frontend/src/views/CRUD/data/database/types.ts b/superset-frontend/src/views/CRUD/data/database/types.ts index 4ffb69535cbe2..0f7cbd1e90854 100644 --- a/superset-frontend/src/views/CRUD/data/database/types.ts +++ b/superset-frontend/src/views/CRUD/data/database/types.ts @@ -92,6 +92,7 @@ export type DatabaseObject = { version?: string; cost_estimate_enabled?: boolean; // in SQL Lab + allows_preview_data?: boolean; // in SQL Lab }; // Temporary storage diff --git a/superset/dashboards/schemas.py b/superset/dashboards/schemas.py index d2f55d2e15ba8..82cb9ac5b8d8b 100644 --- a/superset/dashboards/schemas.py +++ b/superset/dashboards/schemas.py @@ -175,6 +175,7 @@ class DatabaseSchema(Schema): allows_subquery = fields.Bool() allows_cost_estimate = fields.Bool() allows_virtual_table_explore = fields.Bool() + allows_preview_data = fields.Bool() explore_database_id = fields.Int() diff --git a/superset/databases/api.py b/superset/databases/api.py index 5f748855f7488..27d02e7575e4a 100644 --- a/superset/databases/api.py +++ b/superset/databases/api.py @@ -145,7 +145,7 @@ class DatabaseRestApi(BaseSupersetModelRestApi): "extra", "force_ctas_schema", "id", - "preview_data", + "allows_preview_data", ] add_columns = [ "database_name", diff --git a/superset/databases/schemas.py b/superset/databases/schemas.py index b1754791444a3..5abc6e0181761 100644 --- a/superset/databases/schemas.py +++ b/superset/databases/schemas.py @@ -119,7 +119,7 @@ "This should be used with Presto DBs so that the syntax is correct
" "5. The ``allows_virtual_table_explore`` field is a boolean specifying " "whether or not the Explore button in SQL Lab results is shown.
" - "6. The ``preview_data`` field is a boolean specifying whether or not data " + "6. 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.", True, ) diff --git a/superset/views/core.py b/superset/views/core.py index a3d160161326d..dee6027ee602e 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -178,7 +178,7 @@ "expose_in_sqllab", "force_ctas_schema", "id", - "preview_data", + "allows_preview_data", ] DATASOURCE_MISSING_ERR = __("The data source seems to have been deleted") diff --git a/superset/views/database/mixins.py b/superset/views/database/mixins.py index 5382181d2a3ff..70653db7e45b7 100644 --- a/superset/views/database/mixins.py +++ b/superset/views/database/mixins.py @@ -145,7 +145,9 @@ class DatabaseMixin: "4. the ``version`` field is a string specifying the this db's version. " "This should be used with Presto DBs so that the syntax is correct
" "5. The ``allows_virtual_table_explore`` field is a boolean specifying " - "whether or not the Explore button in SQL Lab results is shown.", + "whether or not the Explore button in SQL Lab results is shown
" + "6. 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.", True, ), "encrypted_extra": utils.markdown( diff --git a/tests/integration_tests/core_tests.py b/tests/integration_tests/core_tests.py index a4c95a20db4f7..4c041eb1c8027 100644 --- a/tests/integration_tests/core_tests.py +++ b/tests/integration_tests/core_tests.py @@ -1549,6 +1549,29 @@ def test_virtual_table_explore_visibility(self): database.extra = json.dumps(extra) self.assertEqual(database.allows_virtual_table_explore, True) + def test_preview_data_visibility(self): + # test that default visibility it set to True + database = utils.get_example_database() + self.assertEqual(database.allows_preview_data, True) + + # test that visibility is disabled when extra is set to False + extra = database.get_extra() + extra["allows_preview_data"] = False + database.extra = json.dumps(extra) + self.assertEqual(database.allows_preview_data, False) + + # test that visibility is enabled when extra is set to True + extra = database.get_extra() + extra["allows_preview_data"] = True + database.extra = json.dumps(extra) + self.assertEqual(database.allows_preview_data, True) + + # test that visibility is not broken with bad values + extra = database.get_extra() + extra["allows_preview_data"] = "trash value" + database.extra = json.dumps(extra) + self.assertEqual(database.allows_preview_data, True) + def test_explore_database_id(self): database = superset.utils.database.get_example_database() explore_database = superset.utils.database.get_example_database() diff --git a/tests/integration_tests/databases/api_tests.py b/tests/integration_tests/databases/api_tests.py index 78d7285e010e7..7e7568f3a5e1c 100644 --- a/tests/integration_tests/databases/api_tests.py +++ b/tests/integration_tests/databases/api_tests.py @@ -172,6 +172,7 @@ def test_get_items(self): "allow_multi_schema_metadata_fetch", "allow_run_async", "allows_cost_estimate", + "allows_preview_data", "allows_subquery", "allows_virtual_table_explore", "backend", @@ -185,6 +186,7 @@ def test_get_items(self): "force_ctas_schema", "id", ] + self.assertGreater(response["count"], 0) self.assertEqual(list(response["result"][0].keys()), expected_columns) From bf2174b718aaa936320529f7aa5bc92ea796d2de Mon Sep 17 00:00:00 2001 From: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com> Date: Fri, 25 Feb 2022 07:38:46 -0500 Subject: [PATCH 03/14] Fixed some issues that were caused by the merge conficts --- .../views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx | 6 ------ superset/models/core.py | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx index 1ebb2ec74034c..d52be96cf6368 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx @@ -492,12 +492,6 @@ const ExtraOptions = ({ 'The engine_params object gets unpacked into the sqlalchemy.create_engine call.', )} -
- {t( - '6. The preview_data field is a boolean specifying whether or not data ' + - 'preview queries will be run when fetching table metadata in SQL Lab.', - )} -
diff --git a/superset/models/core.py b/superset/models/core.py index 1a70d1d32341e..b630662aab6d8 100755 --- a/superset/models/core.py +++ b/superset/models/core.py @@ -209,8 +209,8 @@ def allows_virtual_table_explore(self) -> bool: return bool(extra.get("allows_virtual_table_explore", True)) @property - def preview_data(self) -> bool: - return bool(self.get_extra().get("preview_data", True)) + def explore_database_id(self) -> int: + return self.get_extra().get("explore_database_id", self.id) @property def allows_preview_data(self) -> bool: From b748285f88dc495f76fcddc8646d5ae563ef2bd8 Mon Sep 17 00:00:00 2001 From: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com> Date: Fri, 25 Feb 2022 08:03:19 -0500 Subject: [PATCH 04/14] Modified the code to fix the problem where some of the tests were failing --- superset-frontend/src/SqlLab/actions/sqlLab.js | 2 +- superset/models/core.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js index fa7639b4223d5..bb7990d04d0c8 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.js @@ -1095,7 +1095,7 @@ export function addTable(query, database, tableName, schemaName) { }) : Promise.resolve({ json: { id: shortid.generate() } }); - if (database.preview_data && database.id == query.dbId) { + if (database.allows_preview_data && database.id == query.dbId) { const dataPreviewQuery = { id: shortid.generate(), dbId: query.dbId, diff --git a/superset/models/core.py b/superset/models/core.py index b630662aab6d8..1409f4f9b348e 100755 --- a/superset/models/core.py +++ b/superset/models/core.py @@ -229,7 +229,7 @@ def data(self) -> Dict[str, Any]: "allows_virtual_table_explore": self.allows_virtual_table_explore, "explore_database_id": self.explore_database_id, "parameters": self.parameters, - "allows_preview_data": self.preview_data, + "allows_preview_data": self.allows_preview_data, "parameters_schema": self.parameters_schema, } From 8eb76a99b16937038b22e18d519b8e4b464765ec Mon Sep 17 00:00:00 2001 From: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com> Date: Fri, 25 Feb 2022 08:37:49 -0500 Subject: [PATCH 05/14] Ran pre-commit hook to remove any issues it would pick up --- superset-frontend/src/SqlLab/actions/sqlLab.js | 2 +- tests/integration_tests/databases/api_tests.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js index bb7990d04d0c8..c75afd1154658 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.js @@ -1095,7 +1095,7 @@ export function addTable(query, database, tableName, schemaName) { }) : Promise.resolve({ json: { id: shortid.generate() } }); - if (database.allows_preview_data && database.id == query.dbId) { + if (database.allows_preview_data && database.id === query.dbId) { const dataPreviewQuery = { id: shortid.generate(), dbId: query.dbId, diff --git a/tests/integration_tests/databases/api_tests.py b/tests/integration_tests/databases/api_tests.py index 7e7568f3a5e1c..30a1855de8792 100644 --- a/tests/integration_tests/databases/api_tests.py +++ b/tests/integration_tests/databases/api_tests.py @@ -186,7 +186,7 @@ def test_get_items(self): "force_ctas_schema", "id", ] - + self.assertGreater(response["count"], 0) self.assertEqual(list(response["result"][0].keys()), expected_columns) From fb1343bee81f94dbc7b93480e606468eec4f51e7 Mon Sep 17 00:00:00 2001 From: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com> Date: Fri, 25 Feb 2022 08:47:57 -0500 Subject: [PATCH 06/14] Fixed a pylint error where a line was too long --- superset/views/database/mixins.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/superset/views/database/mixins.py b/superset/views/database/mixins.py index 70653db7e45b7..5a6cd56930b6f 100644 --- a/superset/views/database/mixins.py +++ b/superset/views/database/mixins.py @@ -146,8 +146,9 @@ class DatabaseMixin: "This should be used with Presto DBs so that the syntax is correct
" "5. The ``allows_virtual_table_explore`` field is a boolean specifying " "whether or not the Explore button in SQL Lab results is shown
" - "6. 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.", + "6. 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.", True, ), "encrypted_extra": utils.markdown( From f91c69199e593ae3cf2d4f13f9135af4d324ad24 Mon Sep 17 00:00:00 2001 From: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com> Date: Fri, 25 Feb 2022 09:47:30 -0500 Subject: [PATCH 07/14] Fixed the test so it no longer fails, since it was looking for 7 checkboxes and tooltips but there are now 8 --- .../CRUD/data/database/DatabaseModal/index.test.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx index 6fcbfdad43848..2e5d6a6cef48a 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx @@ -591,6 +591,12 @@ describe('DatabaseModal', () => { const allowDbExplorationText = screen.getByText( /allow this database to be explored/i, ); + const allowSQLLabDataPreviewQueriesCheckbox = screen.getByRole('checkbox', { + name: /Allow SQL Lab data preview queries/i, + }); + const allowSQLLabDataPreviewQueriesText = screen.getByText( + /Allow SQL Lab data preview queries/i, + ); // ---------- Assertions ---------- const visibleComponents = [ @@ -627,6 +633,7 @@ describe('DatabaseModal', () => { allowMultiSchemaMDFetchText, enableQueryCostEstimationText, allowDbExplorationText, + allowSQLLabDataPreviewQueriesText, ]; // These components exist in the DOM but are not visible const invisibleComponents = [ @@ -637,6 +644,7 @@ describe('DatabaseModal', () => { allowMultiSchemaMDFetchCheckbox, enableQueryCostEstimationCheckbox, allowDbExplorationCheckbox, + allowSQLLabDataPreviewQueriesCheckbox, ]; visibleComponents.forEach(component => { @@ -645,8 +653,8 @@ describe('DatabaseModal', () => { invisibleComponents.forEach(component => { expect(component).not.toBeVisible(); }); - expect(checkboxOffSVGs).toHaveLength(7); - expect(tooltipIcons).toHaveLength(7); + expect(checkboxOffSVGs).toHaveLength(8); + expect(tooltipIcons).toHaveLength(8); }); it('renders the "Advanced" - PERFORMANCE tab correctly', async () => { From 8459ad6b5c4f1510d8fd88579bf4abcf42098946 Mon Sep 17 00:00:00 2001 From: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com> Date: Fri, 25 Feb 2022 09:51:06 -0500 Subject: [PATCH 08/14] Fixed the test so it no longer fails, since it was looking for 7 checkboxes and tooltips but there are now 8 --- .../CRUD/data/database/DatabaseModal/index.test.jsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx index 2e5d6a6cef48a..00246833ff8db 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx @@ -591,9 +591,12 @@ describe('DatabaseModal', () => { const allowDbExplorationText = screen.getByText( /allow this database to be explored/i, ); - const allowSQLLabDataPreviewQueriesCheckbox = screen.getByRole('checkbox', { - name: /Allow SQL Lab data preview queries/i, - }); + const allowSQLLabDataPreviewQueriesCheckbox = screen.getByRole( + 'checkbox', + { + name: /Allow SQL Lab data preview queries/i, + }, + ); const allowSQLLabDataPreviewQueriesText = screen.getByText( /Allow SQL Lab data preview queries/i, ); @@ -616,6 +619,7 @@ describe('DatabaseModal', () => { checkboxOffSVGs[4], checkboxOffSVGs[5], checkboxOffSVGs[6], + checkboxOffSVGs[7], tooltipIcons[0], tooltipIcons[1], tooltipIcons[2], @@ -623,6 +627,7 @@ describe('DatabaseModal', () => { tooltipIcons[4], tooltipIcons[5], tooltipIcons[6], + tooltipIcons[7], exposeInSQLLabText, allowCTASText, allowCVASText, From a9ea6f25c7e332a98410683f26bbaa815828d3ae Mon Sep 17 00:00:00 2001 From: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com> Date: Tue, 8 Mar 2022 09:02:53 -0500 Subject: [PATCH 09/14] Updated files to include the recommendations Ville made in comments on 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 --- docs/static/resources/openapi.json | 12 +++++------ .../src/SqlLab/actions/sqlLab.js | 2 +- .../src/SqlLab/actions/sqlLab.test.js | 12 +++++++---- .../DatabaseSelector.test.tsx | 8 ++++---- .../database/DatabaseModal/ExtraOptions.tsx | 8 ++++---- .../database/DatabaseModal/index.test.jsx | 12 +++++------ .../src/views/CRUD/data/database/types.ts | 2 +- superset/dashboards/schemas.py | 2 +- superset/databases/api.py | 2 +- superset/databases/schemas.py | 2 +- superset/models/core.py | 6 +++--- superset/views/core.py | 2 +- superset/views/database/mixins.py | 2 +- tests/integration_tests/core_tests.py | 20 +++++++++---------- .../integration_tests/databases/api_tests.py | 4 ++-- 15 files changed, 50 insertions(+), 46 deletions(-) diff --git a/docs/static/resources/openapi.json b/docs/static/resources/openapi.json index de0439dc70aa1..3b69cc67aac9c 100644 --- a/docs/static/resources/openapi.json +++ b/docs/static/resources/openapi.json @@ -2252,7 +2252,7 @@ "allows_virtual_table_explore": { "type": "boolean" }, - "allows_preview_data": { + "disable_preview_data": { "type": "boolean" }, "backend": { @@ -2479,7 +2479,7 @@ "allows_virtual_table_explore": { "readOnly": true }, - "allows_preview_data": { + "disable_preview_data": { "readOnly": true }, "backend": { @@ -2581,7 +2581,7 @@ "type": "boolean" }, "extra": { - "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. 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.

", + "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. The disable_preview_data field is a boolean specifying whether or not data preview queries will be run when fetching table metadata in SQL Lab.

", "type": "string" }, "force_ctas_schema": { @@ -2673,7 +2673,7 @@ "type": "boolean" }, "extra": { - "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. 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.

", + "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. The disable_preview_data field is a boolean specifying whether or not data preview queries will be run when fetching table metadata in SQL Lab.

", "type": "string" }, "force_ctas_schema": { @@ -2730,7 +2730,7 @@ "type": "string" }, "extra": { - "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. 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.

", + "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. The disable_preview_data field is a boolean specifying whether or not data preview queries will be run when fetching table metadata in SQL Lab.

", "type": "string" }, "impersonate_user": { @@ -2778,7 +2778,7 @@ "type": "string" }, "extra": { - "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. 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.

", + "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. The disable_preview_data field is a boolean specifying whether or not data preview queries will be run when fetching table metadata in SQL Lab.

", "type": "string" }, "impersonate_user": { diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js index c75afd1154658..be62b749b3b94 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.js @@ -1095,7 +1095,7 @@ export function addTable(query, database, tableName, schemaName) { }) : Promise.resolve({ json: { id: shortid.generate() } }); - if (database.allows_preview_data && database.id === query.dbId) { + if (!(database.disable_preview_data) && database.id === query.dbId) { const dataPreviewQuery = { id: shortid.generate(), dbId: query.dbId, diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.test.js b/superset-frontend/src/SqlLab/actions/sqlLab.test.js index eee65cea73e75..80c7c2e5f8aaf 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.test.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.test.js @@ -727,7 +727,7 @@ describe('async actions', () => { it('updates the table schema state in the backend', () => { expect.assertions(5); - const database = { allows_preview_data: false }; + const database = { disable_preview_data: true }; const tableName = 'table'; const schemaName = 'schema'; const store = mockStore({}); @@ -755,7 +755,7 @@ describe('async actions', () => { }); it('updates and runs data preview query when configured', () => { - expect.assertions(2); + expect.assertions(5); const results = { data: mockBigNumber, @@ -766,7 +766,7 @@ describe('async actions', () => { overwriteRoutes: true, }); - const database = { allows_preview_data: true, id: 1 }; + const database = { disable_preview_data: false, id: 1 }; const tableName = 'table'; const schemaName = 'schema'; const store = mockStore({}); @@ -785,7 +785,11 @@ describe('async actions', () => { expect(store.getActions().map(a => a.type)).toEqual( expectedActionTypes, ); - + expect(fetchMock.calls(updateTableSchemaEndpoint)).toHaveLength(1); + expect(fetchMock.calls(getTableMetadataEndpoint)).toHaveLength(1); + expect(fetchMock.calls(getExtraTableMetadataEndpoint)).toHaveLength( + 1, + ); // tab state is not updated, since the query is a data preview expect(fetchMock.calls(updateTabStateEndpoint)).toHaveLength(0); }); diff --git a/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx b/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx index f802aad5faa93..85b89a8851556 100644 --- a/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx +++ b/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx @@ -76,7 +76,7 @@ beforeEach(() => { allows_cost_estimate: 'Allows Cost Estimate', allows_subquery: 'Allows Subquery', allows_virtual_table_explore: 'Allows Virtual Table Explore', - allows_preview_data: 'Allows SQL Lab Data Preview', + disable_preview_data: 'Disables SQL Lab Data Preview', backend: 'Backend', changed_on: 'Changed On', changed_on_delta_humanized: 'Changed On Delta Humanized', @@ -98,7 +98,7 @@ beforeEach(() => { 'allows_cost_estimate', 'allows_subquery', 'allows_virtual_table_explore', - 'allows_preview_data', + 'disable_preview_data', 'backend', 'changed_on', 'changed_on_delta_humanized', @@ -132,7 +132,7 @@ beforeEach(() => { allows_cost_estimate: null, allows_subquery: true, allows_virtual_table_explore: true, - allows_preview_data: true, + disable_preview_data: false, backend: 'postgresql', changed_on: '2021-03-09T19:02:07.141095', changed_on_delta_humanized: 'a day ago', @@ -153,7 +153,7 @@ beforeEach(() => { allows_cost_estimate: null, allows_subquery: true, allows_virtual_table_explore: true, - allows_preview_data: true, + disable_preview_data: false, backend: 'mysql', changed_on: '2021-03-09T19:02:07.141095', changed_on_delta_humanized: 'a day ago', diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx index d52be96cf6368..8eabfa5fc21be 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx @@ -201,15 +201,15 @@ const ExtraOptions = ({
diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx index 00246833ff8db..9db2333573dfa 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.jsx @@ -591,14 +591,14 @@ describe('DatabaseModal', () => { const allowDbExplorationText = screen.getByText( /allow this database to be explored/i, ); - const allowSQLLabDataPreviewQueriesCheckbox = screen.getByRole( + const disableSQLLabDataPreviewQueriesCheckbox = screen.getByRole( 'checkbox', { - name: /Allow SQL Lab data preview queries/i, + name: /Disable SQL Lab data preview queries/i, }, ); - const allowSQLLabDataPreviewQueriesText = screen.getByText( - /Allow SQL Lab data preview queries/i, + const disableSQLLabDataPreviewQueriesText = screen.getByText( + /Disable SQL Lab data preview queries/i, ); // ---------- Assertions ---------- @@ -638,7 +638,7 @@ describe('DatabaseModal', () => { allowMultiSchemaMDFetchText, enableQueryCostEstimationText, allowDbExplorationText, - allowSQLLabDataPreviewQueriesText, + disableSQLLabDataPreviewQueriesText, ]; // These components exist in the DOM but are not visible const invisibleComponents = [ @@ -649,7 +649,7 @@ describe('DatabaseModal', () => { allowMultiSchemaMDFetchCheckbox, enableQueryCostEstimationCheckbox, allowDbExplorationCheckbox, - allowSQLLabDataPreviewQueriesCheckbox, + disableSQLLabDataPreviewQueriesCheckbox, ]; visibleComponents.forEach(component => { diff --git a/superset-frontend/src/views/CRUD/data/database/types.ts b/superset-frontend/src/views/CRUD/data/database/types.ts index 0f7cbd1e90854..8509072a26b66 100644 --- a/superset-frontend/src/views/CRUD/data/database/types.ts +++ b/superset-frontend/src/views/CRUD/data/database/types.ts @@ -92,7 +92,7 @@ export type DatabaseObject = { version?: string; cost_estimate_enabled?: boolean; // in SQL Lab - allows_preview_data?: boolean; // in SQL Lab + disable_preview_data?: boolean; // in SQL Lab }; // Temporary storage diff --git a/superset/dashboards/schemas.py b/superset/dashboards/schemas.py index 82cb9ac5b8d8b..0b77d37d1717b 100644 --- a/superset/dashboards/schemas.py +++ b/superset/dashboards/schemas.py @@ -175,7 +175,7 @@ class DatabaseSchema(Schema): allows_subquery = fields.Bool() allows_cost_estimate = fields.Bool() allows_virtual_table_explore = fields.Bool() - allows_preview_data = fields.Bool() + disable_preview_data = fields.Bool() explore_database_id = fields.Int() diff --git a/superset/databases/api.py b/superset/databases/api.py index 27d02e7575e4a..89276b39a46a2 100644 --- a/superset/databases/api.py +++ b/superset/databases/api.py @@ -145,7 +145,7 @@ class DatabaseRestApi(BaseSupersetModelRestApi): "extra", "force_ctas_schema", "id", - "allows_preview_data", + "disable_preview_data", ] add_columns = [ "database_name", diff --git a/superset/databases/schemas.py b/superset/databases/schemas.py index 5abc6e0181761..ee2370a1b2b33 100644 --- a/superset/databases/schemas.py +++ b/superset/databases/schemas.py @@ -119,7 +119,7 @@ "This should be used with Presto DBs so that the syntax is correct
" "5. The ``allows_virtual_table_explore`` field is a boolean specifying " "whether or not the Explore button in SQL Lab results is shown.
" - "6. The ``allows_preview_data`` field is a boolean specifying whether or not data " + "6. The ``disable_preview_data`` field is a boolean specifying whether or not data " "preview queries will be run when fetching table metadata in SQL Lab.", True, ) diff --git a/superset/models/core.py b/superset/models/core.py index 1409f4f9b348e..33c613e8bd210 100755 --- a/superset/models/core.py +++ b/superset/models/core.py @@ -213,8 +213,8 @@ def explore_database_id(self) -> int: return self.get_extra().get("explore_database_id", self.id) @property - def allows_preview_data(self) -> bool: - return bool(self.get_extra().get("allows_preview_data", True)) + def disable_preview_data(self) -> bool: + return bool(self.get_extra().get("disable_preview_data", False)) @property def data(self) -> Dict[str, Any]: @@ -229,7 +229,7 @@ def data(self) -> Dict[str, Any]: "allows_virtual_table_explore": self.allows_virtual_table_explore, "explore_database_id": self.explore_database_id, "parameters": self.parameters, - "allows_preview_data": self.allows_preview_data, + "disable_preview_data": self.disable_preview_data, "parameters_schema": self.parameters_schema, } diff --git a/superset/views/core.py b/superset/views/core.py index dee6027ee602e..79bfcf5346443 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -178,7 +178,7 @@ "expose_in_sqllab", "force_ctas_schema", "id", - "allows_preview_data", + "disable_preview_data", ] DATASOURCE_MISSING_ERR = __("The data source seems to have been deleted") diff --git a/superset/views/database/mixins.py b/superset/views/database/mixins.py index 5a6cd56930b6f..ba4a908378f59 100644 --- a/superset/views/database/mixins.py +++ b/superset/views/database/mixins.py @@ -146,7 +146,7 @@ class DatabaseMixin: "This should be used with Presto DBs so that the syntax is correct
" "5. The ``allows_virtual_table_explore`` field is a boolean specifying " "whether or not the Explore button in SQL Lab results is shown
" - "6. The ``allows_preview_data`` field is a boolean specifying whether or" + "6. The ``disable_preview_data`` field is a boolean specifying whether or" "not data preview queries will be run when fetching table metadata in" "SQL Lab.", True, diff --git a/tests/integration_tests/core_tests.py b/tests/integration_tests/core_tests.py index 4c041eb1c8027..deb4a2ba702a0 100644 --- a/tests/integration_tests/core_tests.py +++ b/tests/integration_tests/core_tests.py @@ -1550,27 +1550,27 @@ def test_virtual_table_explore_visibility(self): self.assertEqual(database.allows_virtual_table_explore, True) def test_preview_data_visibility(self): - # test that default visibility it set to True + # test that default visibility is allowed database = utils.get_example_database() - self.assertEqual(database.allows_preview_data, True) + self.assertEqual(database.disable_preview_data, False) - # test that visibility is disabled when extra is set to False + # test that visibility is disabled when extra is set to true extra = database.get_extra() - extra["allows_preview_data"] = False + extra["disable_preview_data"] = True database.extra = json.dumps(extra) - self.assertEqual(database.allows_preview_data, False) + self.assertEqual(database.disable_preview_data, True) - # test that visibility is enabled when extra is set to True + # test that visibility is enabled when extra is set to false extra = database.get_extra() - extra["allows_preview_data"] = True + extra["disable_preview_data"] = False database.extra = json.dumps(extra) - self.assertEqual(database.allows_preview_data, True) + self.assertEqual(database.disable_preview_data, False) # test that visibility is not broken with bad values extra = database.get_extra() - extra["allows_preview_data"] = "trash value" + extra["disable_preview_data"] = "trash value" database.extra = json.dumps(extra) - self.assertEqual(database.allows_preview_data, True) + self.assertEqual(database.disable_preview_data, False) def test_explore_database_id(self): database = superset.utils.database.get_example_database() diff --git a/tests/integration_tests/databases/api_tests.py b/tests/integration_tests/databases/api_tests.py index 30a1855de8792..49153ead79c46 100644 --- a/tests/integration_tests/databases/api_tests.py +++ b/tests/integration_tests/databases/api_tests.py @@ -172,7 +172,6 @@ def test_get_items(self): "allow_multi_schema_metadata_fetch", "allow_run_async", "allows_cost_estimate", - "allows_preview_data", "allows_subquery", "allows_virtual_table_explore", "backend", @@ -180,13 +179,14 @@ def test_get_items(self): "changed_on_delta_humanized", "created_by", "database_name", + "disable_preview_data", "explore_database_id", "expose_in_sqllab", "extra", "force_ctas_schema", "id", ] - + self.assertGreater(response["count"], 0) self.assertEqual(list(response["result"][0].keys()), expected_columns) From 6bb15c2650654c84a94a8d4c307bd19f2e47cc2a Mon Sep 17 00:00:00 2001 From: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com> Date: Tue, 8 Mar 2022 14:54:26 -0500 Subject: [PATCH 10/14] Fixed the disable_preview_data function so that if a 'trash value' string is passed into the parameter instead of a boolean value, it will return False --- superset/models/core.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/superset/models/core.py b/superset/models/core.py index 33c613e8bd210..c42a184de329a 100755 --- a/superset/models/core.py +++ b/superset/models/core.py @@ -214,7 +214,11 @@ def explore_database_id(self) -> int: @property def disable_preview_data(self) -> bool: - return bool(self.get_extra().get("disable_preview_data", False)) + # this will prevent any 'trash value' strings from going through + if (self.get_extra().get("disable_preview_data", False) is not True): + return False + else: + return True @property def data(self) -> Dict[str, Any]: From 75b6067d17cca51713941ca7f8873ddc6a22dd7b Mon Sep 17 00:00:00 2001 From: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com> Date: Thu, 10 Mar 2022 12:02:09 -0500 Subject: [PATCH 11/14] Minor modification to correct an error pointed out by prettier/prettier --- superset-frontend/src/SqlLab/actions/sqlLab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js index be62b749b3b94..a75a03edbb77d 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.js @@ -1095,7 +1095,7 @@ export function addTable(query, database, tableName, schemaName) { }) : Promise.resolve({ json: { id: shortid.generate() } }); - if (!(database.disable_preview_data) && database.id === query.dbId) { + if (!database.disable_preview_data && database.id === query.dbId) { const dataPreviewQuery = { id: shortid.generate(), dbId: query.dbId, From ac3df140c7e10ee67943e64d78a75dcd63af91bf Mon Sep 17 00:00:00 2001 From: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com> Date: Thu, 10 Mar 2022 13:08:32 -0500 Subject: [PATCH 12/14] Fixed an error detected by pylint --- superset/models/core.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/superset/models/core.py b/superset/models/core.py index c42a184de329a..8fa8d764566b2 100755 --- a/superset/models/core.py +++ b/superset/models/core.py @@ -215,10 +215,9 @@ def explore_database_id(self) -> int: @property def disable_preview_data(self) -> bool: # this will prevent any 'trash value' strings from going through - if (self.get_extra().get("disable_preview_data", False) is not True): + if self.get_extra().get("disable_preview_data", False) is not True: return False - else: - return True + return True @property def data(self) -> Dict[str, Any]: From f7312b7cc596fad138759c84e747804875b1b810 Mon Sep 17 00:00:00 2001 From: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com> Date: Thu, 10 Mar 2022 13:22:33 -0500 Subject: [PATCH 13/14] Ran the pre-commit hook --- tests/integration_tests/databases/api_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration_tests/databases/api_tests.py b/tests/integration_tests/databases/api_tests.py index 49153ead79c46..fbf9e9a7209b5 100644 --- a/tests/integration_tests/databases/api_tests.py +++ b/tests/integration_tests/databases/api_tests.py @@ -186,7 +186,7 @@ def test_get_items(self): "force_ctas_schema", "id", ] - + self.assertGreater(response["count"], 0) self.assertEqual(list(response["result"][0].keys()), expected_columns) From bb4974fd732a65ac774b3ffe54b1b44a62dd512e Mon Sep 17 00:00:00 2001 From: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com> Date: Tue, 15 Mar 2022 08:11:37 -0400 Subject: [PATCH 14/14] Updated tooltip text, as well as changed the 'disable_preview_data' flag to be named 'disable_data_preview' --- docs/static/resources/openapi.json | 12 ++++++------ superset-frontend/src/SqlLab/actions/sqlLab.js | 2 +- .../src/SqlLab/actions/sqlLab.test.js | 4 ++-- .../DatabaseSelector/DatabaseSelector.test.tsx | 8 ++++---- .../data/database/DatabaseModal/ExtraOptions.tsx | 9 +++++---- .../src/views/CRUD/data/database/types.ts | 2 +- superset/dashboards/schemas.py | 2 +- superset/databases/api.py | 2 +- superset/databases/schemas.py | 2 +- superset/models/core.py | 6 +++--- superset/views/core.py | 2 +- superset/views/database/mixins.py | 2 +- tests/integration_tests/core_tests.py | 16 ++++++++-------- tests/integration_tests/databases/api_tests.py | 2 +- 14 files changed, 36 insertions(+), 35 deletions(-) diff --git a/docs/static/resources/openapi.json b/docs/static/resources/openapi.json index fd6d8708eb9e6..1e8c6129f1d44 100644 --- a/docs/static/resources/openapi.json +++ b/docs/static/resources/openapi.json @@ -2248,7 +2248,7 @@ "allows_virtual_table_explore": { "type": "boolean" }, - "disable_preview_data": { + "disable_data_preview": { "type": "boolean" }, "backend": { @@ -2475,7 +2475,7 @@ "allows_virtual_table_explore": { "readOnly": true }, - "disable_preview_data": { + "disable_data_preview": { "readOnly": true }, "backend": { @@ -2577,7 +2577,7 @@ "type": "boolean" }, "extra": { - "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. The disable_preview_data field is a boolean specifying whether or not data preview queries will be run when fetching table metadata in SQL Lab.

", + "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. The disable_data_preview field is a boolean specifying whether or not data preview queries will be run when fetching table metadata in SQL Lab.

", "type": "string" }, "force_ctas_schema": { @@ -2669,7 +2669,7 @@ "type": "boolean" }, "extra": { - "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. The disable_preview_data field is a boolean specifying whether or not data preview queries will be run when fetching table metadata in SQL Lab.

", + "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. The disable_data_preview field is a boolean specifying whether or not data preview queries will be run when fetching table metadata in SQL Lab.

", "type": "string" }, "force_ctas_schema": { @@ -2726,7 +2726,7 @@ "type": "string" }, "extra": { - "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. The disable_preview_data field is a boolean specifying whether or not data preview queries will be run when fetching table metadata in SQL Lab.

", + "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. The disable_data_preview field is a boolean specifying whether or not data preview queries will be run when fetching table metadata in SQL Lab.

", "type": "string" }, "impersonate_user": { @@ -2774,7 +2774,7 @@ "type": "string" }, "extra": { - "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. The disable_preview_data field is a boolean specifying whether or not data preview queries will be run when fetching table metadata in SQL Lab.

", + "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown
6. The disable_data_preview field is a boolean specifying whether or not data preview queries will be run when fetching table metadata in SQL Lab.

", "type": "string" }, "impersonate_user": { diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js index a75a03edbb77d..e13e4263a36cd 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.js @@ -1095,7 +1095,7 @@ export function addTable(query, database, tableName, schemaName) { }) : Promise.resolve({ json: { id: shortid.generate() } }); - if (!database.disable_preview_data && database.id === query.dbId) { + if (!database.disable_data_preview && database.id === query.dbId) { const dataPreviewQuery = { id: shortid.generate(), dbId: query.dbId, diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.test.js b/superset-frontend/src/SqlLab/actions/sqlLab.test.js index d362120a32b64..789ae986bfbe7 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.test.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.test.js @@ -727,7 +727,7 @@ describe('async actions', () => { it('updates the table schema state in the backend', () => { expect.assertions(5); - const database = { disable_preview_data: true }; + const database = { disable_data_preview: true }; const tableName = 'table'; const schemaName = 'schema'; const store = mockStore({}); @@ -766,7 +766,7 @@ describe('async actions', () => { overwriteRoutes: true, }); - const database = { disable_preview_data: false, id: 1 }; + const database = { disable_data_preview: false, id: 1 }; const tableName = 'table'; const schemaName = 'schema'; const store = mockStore({}); diff --git a/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx b/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx index 85b89a8851556..2387c2e2517fe 100644 --- a/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx +++ b/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx @@ -76,7 +76,7 @@ beforeEach(() => { allows_cost_estimate: 'Allows Cost Estimate', allows_subquery: 'Allows Subquery', allows_virtual_table_explore: 'Allows Virtual Table Explore', - disable_preview_data: 'Disables SQL Lab Data Preview', + disable_data_preview: 'Disables SQL Lab Data Preview', backend: 'Backend', changed_on: 'Changed On', changed_on_delta_humanized: 'Changed On Delta Humanized', @@ -98,7 +98,7 @@ beforeEach(() => { 'allows_cost_estimate', 'allows_subquery', 'allows_virtual_table_explore', - 'disable_preview_data', + 'disable_data_preview', 'backend', 'changed_on', 'changed_on_delta_humanized', @@ -132,7 +132,7 @@ beforeEach(() => { allows_cost_estimate: null, allows_subquery: true, allows_virtual_table_explore: true, - disable_preview_data: false, + disable_data_preview: false, backend: 'postgresql', changed_on: '2021-03-09T19:02:07.141095', changed_on_delta_humanized: 'a day ago', @@ -153,7 +153,7 @@ beforeEach(() => { allows_cost_estimate: null, allows_subquery: true, allows_virtual_table_explore: true, - disable_preview_data: false, + disable_data_preview: false, backend: 'mysql', changed_on: '2021-03-09T19:02:07.141095', changed_on_delta_humanized: 'a day ago', diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx index 8eabfa5fc21be..12a712fa35b52 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx @@ -201,16 +201,17 @@ const ExtraOptions = ({
diff --git a/superset-frontend/src/views/CRUD/data/database/types.ts b/superset-frontend/src/views/CRUD/data/database/types.ts index 8509072a26b66..c03891689e90b 100644 --- a/superset-frontend/src/views/CRUD/data/database/types.ts +++ b/superset-frontend/src/views/CRUD/data/database/types.ts @@ -92,7 +92,7 @@ export type DatabaseObject = { version?: string; cost_estimate_enabled?: boolean; // in SQL Lab - disable_preview_data?: boolean; // in SQL Lab + disable_data_preview?: boolean; // in SQL Lab }; // Temporary storage diff --git a/superset/dashboards/schemas.py b/superset/dashboards/schemas.py index 0b77d37d1717b..b1831fdcbbe70 100644 --- a/superset/dashboards/schemas.py +++ b/superset/dashboards/schemas.py @@ -175,7 +175,7 @@ class DatabaseSchema(Schema): allows_subquery = fields.Bool() allows_cost_estimate = fields.Bool() allows_virtual_table_explore = fields.Bool() - disable_preview_data = fields.Bool() + disable_data_preview = fields.Bool() explore_database_id = fields.Int() diff --git a/superset/databases/api.py b/superset/databases/api.py index 89276b39a46a2..83cdf2571a60e 100644 --- a/superset/databases/api.py +++ b/superset/databases/api.py @@ -145,7 +145,7 @@ class DatabaseRestApi(BaseSupersetModelRestApi): "extra", "force_ctas_schema", "id", - "disable_preview_data", + "disable_data_preview", ] add_columns = [ "database_name", diff --git a/superset/databases/schemas.py b/superset/databases/schemas.py index fb87f7198129e..4483b051f1be0 100644 --- a/superset/databases/schemas.py +++ b/superset/databases/schemas.py @@ -119,7 +119,7 @@ "This should be used with Presto DBs so that the syntax is correct
" "5. The ``allows_virtual_table_explore`` field is a boolean specifying " "whether or not the Explore button in SQL Lab results is shown.
" - "6. The ``disable_preview_data`` field is a boolean specifying whether or not data " + "6. The ``disable_data_preview`` field is a boolean specifying whether or not data " "preview queries will be run when fetching table metadata in SQL Lab.", True, ) diff --git a/superset/models/core.py b/superset/models/core.py index 8fa8d764566b2..51f0731009950 100755 --- a/superset/models/core.py +++ b/superset/models/core.py @@ -213,9 +213,9 @@ def explore_database_id(self) -> int: return self.get_extra().get("explore_database_id", self.id) @property - def disable_preview_data(self) -> bool: + def disable_data_preview(self) -> bool: # this will prevent any 'trash value' strings from going through - if self.get_extra().get("disable_preview_data", False) is not True: + if self.get_extra().get("disable_data_preview", False) is not True: return False return True @@ -232,7 +232,7 @@ def data(self) -> Dict[str, Any]: "allows_virtual_table_explore": self.allows_virtual_table_explore, "explore_database_id": self.explore_database_id, "parameters": self.parameters, - "disable_preview_data": self.disable_preview_data, + "disable_data_preview": self.disable_data_preview, "parameters_schema": self.parameters_schema, } diff --git a/superset/views/core.py b/superset/views/core.py index 2864f51a12479..2a441a46851b6 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -177,7 +177,7 @@ "expose_in_sqllab", "force_ctas_schema", "id", - "disable_preview_data", + "disable_data_preview", ] DATASOURCE_MISSING_ERR = __("The data source seems to have been deleted") diff --git a/superset/views/database/mixins.py b/superset/views/database/mixins.py index ba4a908378f59..d5a5157ef4f7b 100644 --- a/superset/views/database/mixins.py +++ b/superset/views/database/mixins.py @@ -146,7 +146,7 @@ class DatabaseMixin: "This should be used with Presto DBs so that the syntax is correct
" "5. The ``allows_virtual_table_explore`` field is a boolean specifying " "whether or not the Explore button in SQL Lab results is shown
" - "6. The ``disable_preview_data`` field is a boolean specifying whether or" + "6. The ``disable_data_preview`` field is a boolean specifying whether or" "not data preview queries will be run when fetching table metadata in" "SQL Lab.", True, diff --git a/tests/integration_tests/core_tests.py b/tests/integration_tests/core_tests.py index f96b1f7ce5392..d0bc616bbf782 100644 --- a/tests/integration_tests/core_tests.py +++ b/tests/integration_tests/core_tests.py @@ -1541,28 +1541,28 @@ def test_virtual_table_explore_visibility(self): database.extra = json.dumps(extra) self.assertEqual(database.allows_virtual_table_explore, True) - def test_preview_data_visibility(self): + def test_data_preview_visibility(self): # test that default visibility is allowed database = utils.get_example_database() - self.assertEqual(database.disable_preview_data, False) + self.assertEqual(database.disable_data_preview, False) # test that visibility is disabled when extra is set to true extra = database.get_extra() - extra["disable_preview_data"] = True + extra["disable_data_preview"] = True database.extra = json.dumps(extra) - self.assertEqual(database.disable_preview_data, True) + self.assertEqual(database.disable_data_preview, True) # test that visibility is enabled when extra is set to false extra = database.get_extra() - extra["disable_preview_data"] = False + extra["disable_data_preview"] = False database.extra = json.dumps(extra) - self.assertEqual(database.disable_preview_data, False) + self.assertEqual(database.disable_data_preview, False) # test that visibility is not broken with bad values extra = database.get_extra() - extra["disable_preview_data"] = "trash value" + extra["disable_data_preview"] = "trash value" database.extra = json.dumps(extra) - self.assertEqual(database.disable_preview_data, False) + self.assertEqual(database.disable_data_preview, False) def test_explore_database_id(self): database = superset.utils.database.get_example_database() diff --git a/tests/integration_tests/databases/api_tests.py b/tests/integration_tests/databases/api_tests.py index fbf9e9a7209b5..928f3d595730d 100644 --- a/tests/integration_tests/databases/api_tests.py +++ b/tests/integration_tests/databases/api_tests.py @@ -179,7 +179,7 @@ def test_get_items(self): "changed_on_delta_humanized", "created_by", "database_name", - "disable_preview_data", + "disable_data_preview", "explore_database_id", "expose_in_sqllab", "extra",