Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(sqllab): Cleanup /tables/... endpoint #21284

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ assists people when migrating to a new version.
- [20799](https://github.com/apache/superset/pull/20799): Presto and Trino engine will now display tracking URL for running queries in SQL Lab. If for some reason you don't want to show the tracking URL (for example, when your data warehouse hasn't enable access for to Presto or Trino UI), update `TRACKING_URL_TRANSFORMER` in `config.py` to return `None`.
- [21002](https://github.com/apache/superset/pull/21002): Support Python 3.10 and bump pandas 1.4 and pyarrow 6.
- [21163](https://github.com/apache/superset/pull/21163): When `GENERIC_CHART_AXES` feature flags set to `True`, the Time Grain control will move below the X-Axis control.

- [21284](https://github.com/apache/superset/pull/21284): The non-functional `MAX_TABLE_NAMES` config key has been removed.

### Breaking Changes

Expand Down
19 changes: 0 additions & 19 deletions docs/static/resources/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3532,9 +3532,6 @@
},
"Database": {
"properties": {
"allow_multi_schema_metadata_fetch": {
"type": "boolean"
},
"allows_cost_estimate": {
"type": "boolean"
},
Expand Down Expand Up @@ -3679,10 +3676,6 @@
"nullable": true,
"type": "boolean"
},
"allow_multi_schema_metadata_fetch": {
"nullable": true,
"type": "boolean"
},
"allow_run_async": {
"nullable": true,
"type": "boolean"
Expand Down Expand Up @@ -3771,10 +3764,6 @@
"nullable": true,
"type": "boolean"
},
"allow_multi_schema_metadata_fetch": {
"nullable": true,
"type": "boolean"
},
"allow_run_async": {
"nullable": true,
"type": "boolean"
Expand Down Expand Up @@ -3870,10 +3859,6 @@
"description": "Allow to upload CSV file data into this databaseIf selected, please set the schemas allowed for csv upload in Extra.",
"type": "boolean"
},
"allow_multi_schema_metadata_fetch": {
"description": "Allow SQL Lab to fetch a list of all tables and all views across all database schemas. For large data warehouse with thousands of tables, this can be expensive and put strain on the system.",
"type": "boolean"
},
"allow_run_async": {
"description": "Operate the database in asynchronous mode, meaning that the queries are executed on remote workers as opposed to on the web server itself. This assumes that you have a Celery worker setup as well as a results backend. Refer to the installation docs for more information.",
"type": "boolean"
Expand Down Expand Up @@ -3971,10 +3956,6 @@
"description": "Allow to upload CSV file data into this databaseIf selected, please set the schemas allowed for csv upload in Extra.",
"type": "boolean"
},
"allow_multi_schema_metadata_fetch": {
"description": "Allow SQL Lab to fetch a list of all tables and all views across all database schemas. For large data warehouse with thousands of tables, this can be expensive and put strain on the system.",
"type": "boolean"
},
"allow_run_async": {
"description": "Operate the database in asynchronous mode, meaning that the queries are executed on remote workers as opposed to on the web server itself. This assumes that you have a Celery worker setup as well as a results backend. Refer to the installation docs for more information.",
"type": "boolean"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"id": 1,
"name": "examples",
"backend": "postgresql",
"allow_multi_schema_metadata_fetch": false,
"allows_subquery": true,
"allows_cost_estimate": null,
"allows_virtual_table_explore": true,
Expand Down
1 change: 0 additions & 1 deletion superset-frontend/spec/fixtures/mockDatasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ export default {
name: 'birth_names',
owners: [{ first_name: 'joe', last_name: 'man', id: 1 }],
database: {
allow_multi_schema_metadata_fetch: null,
name: 'main',
backend: 'sqlite',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ const store = mockStore({
allow_cvas: false,
allow_dml: false,
allow_file_upload: false,
allow_multi_schema_metadata_fetch: false,
allow_run_async: false,
backend: 'postgresql',
database_name: 'examples',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const createProps = (): DatabaseSelectorProps => ({
id: 1,
database_name: 'test',
backend: 'test-postgresql',
allow_multi_schema_metadata_fetch: false,
},
formMode: false,
isDatabaseSelectEnabled: true,
Expand Down Expand Up @@ -69,8 +68,6 @@ beforeEach(() => {
allow_ctas: 'Allow Ctas',
allow_cvas: 'Allow Cvas',
allow_dml: 'Allow Dml',
allow_multi_schema_metadata_fetch:
'Allow Multi Schema Metadata Fetch',
allow_run_async: 'Allow Run Async',
allows_cost_estimate: 'Allows Cost Estimate',
allows_subquery: 'Allows Subquery',
Expand All @@ -92,7 +89,6 @@ beforeEach(() => {
'allow_ctas',
'allow_cvas',
'allow_dml',
'allow_multi_schema_metadata_fetch',
'allow_run_async',
'allows_cost_estimate',
'allows_subquery',
Expand Down Expand Up @@ -126,7 +122,6 @@ beforeEach(() => {
allow_ctas: false,
allow_cvas: false,
allow_dml: false,
allow_multi_schema_metadata_fetch: false,
allow_run_async: false,
allows_cost_estimate: null,
allows_subquery: true,
Expand All @@ -147,7 +142,6 @@ beforeEach(() => {
allow_ctas: false,
allow_cvas: false,
allow_dml: false,
allow_multi_schema_metadata_fetch: false,
allow_run_async: false,
allows_cost_estimate: null,
allows_subquery: true,
Expand Down Expand Up @@ -272,7 +266,6 @@ test('Sends the correct db when changing the database', async () => {
id: 2,
database_name: 'test-mysql',
backend: 'mysql',
allow_multi_schema_metadata_fetch: false,
}),
),
);
Expand Down
4 changes: 0 additions & 4 deletions superset-frontend/src/components/DatabaseSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,12 @@ type DatabaseValue = {
id: number;
database_name: string;
backend: string;
allow_multi_schema_metadata_fetch: boolean;
};

export type DatabaseObject = {
id: number;
database_name: string;
backend: string;
allow_multi_schema_metadata_fetch: boolean;
};

type SchemaValue = { label: string; value: string };
Expand Down Expand Up @@ -199,8 +197,6 @@ export default function DatabaseSelector({
id: row.id,
database_name: row.database_name,
backend: row.backend,
allow_multi_schema_metadata_fetch:
row.allow_multi_schema_metadata_fetch,
}));

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const createProps = (props = {}) => ({
id: 1,
database_name: 'main',
backend: 'sqlite',
allow_multi_schema_metadata_fetch: false,
},
schema: 'test_schema',
handleError: jest.fn(),
Expand Down
10 changes: 4 additions & 6 deletions superset-frontend/src/components/TableSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ export interface TableOption {
}

export const TableOption = ({ table }: { table: Table }) => {
const { label, type, extra } = table;
const { value, type, extra } = table;
return (
<TableLabel title={label}>
<TableLabel title={value}>
{type === 'view' ? (
<Icons.Eye iconSize="m" />
) : (
Expand All @@ -133,7 +133,7 @@ export const TableOption = ({ table }: { table: Table }) => {
size="l"
/>
)}
{label}
{value}
</TableLabel>
);
};
Expand Down Expand Up @@ -286,9 +286,7 @@ const TableSelector: FunctionComponent<TableSelectorProps> = ({
);

function renderTableSelect() {
const disabled =
(currentSchema && !formMode && readOnly) ||
(!currentSchema && !database?.allow_multi_schema_metadata_fetch);
const disabled = (currentSchema && !formMode && readOnly) || !currentSchema;

const header = sqlLabMode ? (
<FormLabel>{t('See table schema')}</FormLabel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,24 +148,6 @@ const ExtraOptions = ({
/>
</div>
</StyledInputContainer>
<StyledInputContainer css={no_margin_bottom}>
<div className="input-container">
<IndeterminateCheckbox
id="allow_multi_schema_metadata_fetch"
indeterminate={false}
checked={!!db?.allow_multi_schema_metadata_fetch}
onChange={onInputChange}
labelText={t('Allow Multi Schema Metadata Fetch')}
/>
<InfoTooltip
tooltip={t(
'Allow SQL Lab to fetch a list of all tables and all views across all database ' +
'schemas. For large data warehouse with thousands of tables, this can be ' +
'expensive and put strain on the system.',
)}
/>
</div>
</StyledInputContainer>
<StyledInputContainer css={no_margin_bottom}>
<div className="input-container">
<IndeterminateCheckbox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,12 +573,6 @@ describe('DatabaseModal', () => {
name: /allow dml/i,
});
const allowDMLText = screen.getByText(/allow dml/i);
const allowMultiSchemaMDFetchCheckbox = screen.getByRole('checkbox', {
name: /allow multi schema metadata fetch/i,
});
const allowMultiSchemaMDFetchText = screen.getByText(
/allow multi schema metadata fetch/i,
);
const enableQueryCostEstimationCheckbox = screen.getByRole('checkbox', {
name: /enable query cost estimation/i,
});
Expand Down Expand Up @@ -619,23 +613,20 @@ describe('DatabaseModal', () => {
checkboxOffSVGs[4],
checkboxOffSVGs[5],
checkboxOffSVGs[6],
checkboxOffSVGs[7],
tooltipIcons[0],
tooltipIcons[1],
tooltipIcons[2],
tooltipIcons[3],
tooltipIcons[4],
tooltipIcons[5],
tooltipIcons[6],
tooltipIcons[7],
exposeInSQLLabText,
allowCTASText,
allowCVASText,
CTASCVASLabelText,
CTASCVASInput,
CTASCVASHelperText,
allowDMLText,
allowMultiSchemaMDFetchText,
enableQueryCostEstimationText,
allowDbExplorationText,
disableSQLLabDataPreviewQueriesText,
Expand All @@ -646,7 +637,6 @@ describe('DatabaseModal', () => {
allowCTASCheckbox,
allowCVASCheckbox,
allowDMLCheckbox,
allowMultiSchemaMDFetchCheckbox,
enableQueryCostEstimationCheckbox,
allowDbExplorationCheckbox,
disableSQLLabDataPreviewQueriesCheckbox,
Expand All @@ -658,8 +648,8 @@ describe('DatabaseModal', () => {
invisibleComponents.forEach(component => {
expect(component).not.toBeVisible();
});
expect(checkboxOffSVGs).toHaveLength(8);
expect(tooltipIcons).toHaveLength(8);
expect(checkboxOffSVGs).toHaveLength(7);
expect(tooltipIcons).toHaveLength(7);
});

test('renders the "Advanced" - PERFORMANCE tab correctly', async () => {
Expand Down
1 change: 0 additions & 1 deletion superset-frontend/src/views/CRUD/data/database/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export type DatabaseObject = {
allow_ctas?: boolean;
allow_cvas?: boolean;
allow_dml?: boolean;
allow_multi_schema_metadata_fetch?: boolean;
force_ctas_schema?: string;

// Security
Expand Down
33 changes: 0 additions & 33 deletions superset/cli/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

import superset.utils.database as database_utils
from superset.extensions import db
from superset.utils.core import override_user
from superset.utils.encrypt import SecretsMigrator

logger = logging.getLogger(__name__)
Expand All @@ -53,38 +52,6 @@ def set_database_uri(database_name: str, uri: str, skip_create: bool) -> None:
database_utils.get_or_create_db(database_name, uri, not skip_create)


@click.command()
@with_appcontext
@click.option(
"--username",
"-u",
default=None,
help=(
"Specify which user should execute the underlying SQL queries. If undefined "
"defaults to the user registered with the database connection."
),
)
def update_datasources_cache(username: Optional[str]) -> None:
"""Refresh sqllab datasources cache"""
# pylint: disable=import-outside-toplevel
from superset import security_manager
from superset.models.core import Database

with override_user(security_manager.find_user(username)):
for database in db.session.query(Database).all():
if database.allow_multi_schema_metadata_fetch:
print("Fetching {} datasources ...".format(database.name))
try:
database.get_all_table_names_in_database(
force=True, cache=True, cache_timeout=24 * 60 * 60
)
database.get_all_view_names_in_database(
force=True, cache=True, cache_timeout=24 * 60 * 60
)
except Exception as ex: # pylint: disable=broad-except
print("{}".format(str(ex)))


@click.command()
@with_appcontext
def sync_tags() -> None:
Expand Down
3 changes: 0 additions & 3 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,9 +751,6 @@ def _try_json_readsha(filepath: str, length: int) -> Optional[str]:
# the SQL Lab UI
DEFAULT_SQLLAB_LIMIT = 1000

# Maximum number of tables/views displayed in the dropdown window in SQL Lab.
MAX_TABLE_NAMES = 3000

# Adds a warning message on sqllab save query and schedule query modals.
SQLLAB_SAVE_WARNING_MESSAGE = None
SQLLAB_SCHEDULE_WARNING_MESSAGE = None
Expand Down
1 change: 0 additions & 1 deletion superset/dashboards/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ class DatabaseSchema(Schema):
id = fields.Int()
name = fields.String()
backend = fields.String()
allow_multi_schema_metadata_fetch = fields.Bool() # pylint: disable=invalid-name
allows_subquery = fields.Bool()
allows_cost_estimate = fields.Bool()
allows_virtual_table_explore = fields.Bool()
Expand Down
3 changes: 0 additions & 3 deletions superset/databases/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
"allow_dml",
"backend",
"force_ctas_schema",
"allow_multi_schema_metadata_fetch",
"impersonate_user",
"masked_encrypted_extra",
"extra",
Expand All @@ -136,7 +135,6 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
"allow_ctas",
"allow_cvas",
"allow_dml",
"allow_multi_schema_metadata_fetch",
"allow_run_async",
"allows_cost_estimate",
"allows_subquery",
Expand Down Expand Up @@ -167,7 +165,6 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
"configuration_method",
"force_ctas_schema",
"impersonate_user",
"allow_multi_schema_metadata_fetch",
"extra",
"encrypted_extra",
"server_cert",
Expand Down
Loading