From 86eaed54d49163c1ab5d9ef7459cbebade049670 Mon Sep 17 00:00:00 2001 From: John Bodley Date: Thu, 11 May 2023 14:34:46 -0700 Subject: [PATCH] chore: Update QUERY_LOGGER and SQL_QUERY_MUTATOR signatures --- UPDATING.md | 2 +- superset/config.py | 2 -- superset/connectors/sqla/models.py | 4 +--- superset/db_engine_specs/base.py | 3 +-- superset/models/core.py | 4 ---- superset/models/helpers.py | 1 - superset/sql_lab.py | 3 --- superset/sql_validators/presto_db.py | 3 +-- 8 files changed, 4 insertions(+), 18 deletions(-) diff --git a/UPDATING.md b/UPDATING.md index 36f3645146ab7..7ecb299fc5285 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -24,7 +24,6 @@ assists people when migrating to a new version. ## Next -- [23785](https://github.com/apache/superset/pull/23785) Deprecated the following feature flags: `CLIENT_CACHE`, `DASHBOARD_CACHE`, `DASHBOARD_FILTERS_EXPERIMENTAL`, `DASHBOARD_NATIVE_FILTERS`, `DASHBOARD_NATIVE_FILTERS_SET`, `DISABLE_DATASET_SOURCE_EDIT`, `ENABLE_EXPLORE_JSON_CSRF_PROTECTION`, `REMOVE_SLICE_LEVEL_LABEL_COLORS`. It also removed `DASHBOARD_EDIT_CHART_IN_NEW_TAB` as the feature is supported without the need for a feature flag. - [23652](https://github.com/apache/superset/pull/23652) Enables GENERIC_CHART_AXES feature flag by default. - [23226](https://github.com/apache/superset/pull/23226) Migrated endpoint `/estimate_query_cost/` to `/api/v1/sqllab/estimate/`. Corresponding permissions are can estimate query cost on SQLLab. Make sure you add/replace the necessary permissions on any custom roles you may have. - [22809](https://github.com/apache/superset/pull/22809): Migrated endpoint `/superset/sql_json` and `/superset/results/` to `/api/v1/sqllab/execute/` and `/api/v1/sqllab/results/` respectively. Corresponding permissions are `can sql_json on Superset` to `can execute on SQLLab`, `can results on Superset` to `can results on SQLLab`. Make sure you add/replace the necessary permissions on any custom roles you may have. @@ -50,6 +49,7 @@ assists people when migrating to a new version. ### Breaking Changes +- [23785](https://github.com/apache/superset/pull/23785) Deprecated the following feature flags: `CLIENT_CACHE`, `DASHBOARD_CACHE`, `DASHBOARD_FILTERS_EXPERIMENTAL`, `DASHBOARD_NATIVE_FILTERS`, `DASHBOARD_NATIVE_FILTERS_SET`, `DISABLE_DATASET_SOURCE_EDIT`, `ENABLE_EXPLORE_JSON_CSRF_PROTECTION`, `REMOVE_SLICE_LEVEL_LABEL_COLORS`. It also removed `DASHBOARD_EDIT_CHART_IN_NEW_TAB` as the feature is supported without the need for a feature flag. - [22801](https://github.com/apache/superset/pull/22801): The Thumbnails feature has been changed to execute as the currently logged in user by default, falling back to the selenium user for anonymous users. To continue always using the selenium user, please add the following to your `superset_config.py`: `THUMBNAILS_EXECUTE_AS = ["selenium"]` - [22799](https://github.com/apache/superset/pull/22799): Alerts & Reports has been changed to execute as the owner of the alert/report by default, giving priority to the last modifier and then the creator if either is contained within the list of owners, otherwise the first owner will be used. To continue using the selenium user, please add the following to your `superset_config.py`: `ALERT_REPORTS_EXECUTE_AS = ["selenium"]` - [23651](https://github.com/apache/superset/pull/23651): Removes UX_BETA feature flag. diff --git a/superset/config.py b/superset/config.py index afb6504ee069b..63cabf1c45a4c 100644 --- a/superset/config.py +++ b/superset/config.py @@ -834,7 +834,6 @@ class D3Format(TypedDict, total=False): # database, # query, # schema=None, -# user=None, # TODO(john-bodley): Deprecate in 3.0. # client=None, # security_manager=None, # log_params=None, @@ -1188,7 +1187,6 @@ def CSV_TO_HIVE_UPLOAD_DIRECTORY_FUNC( # pylint: disable=invalid-name # # def SQL_QUERY_MUTATOR( # sql, -# user_name=user_name, # TODO(john-bodley): Deprecate in 3.0. # security_manager=security_manager, # database=database, # ): diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py index e339f7b1f4c9e..4b69055d4e696 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -117,7 +117,7 @@ from superset.sql_parse import ParsedQuery, sanitize_clause from superset.superset_typing import AdhocColumn, AdhocMetric, Metric, QueryObjectDict from superset.utils import core as utils -from superset.utils.core import GenericDataType, get_username, MediumText +from superset.utils.core import GenericDataType, MediumText config = app.config metadata = Model.metadata # pylint: disable=no-member @@ -829,8 +829,6 @@ def mutate_query_from_config(self, sql: str) -> str: if sql_query_mutator and not mutate_after_split: sql = sql_query_mutator( sql, - # TODO(john-bodley): Deprecate in 3.0. - user_name=get_username(), security_manager=security_manager, database=self.database, ) diff --git a/superset/db_engine_specs/base.py b/superset/db_engine_specs/base.py index 98fb60c27565b..68724d08b24ae 100644 --- a/superset/db_engine_specs/base.py +++ b/superset/db_engine_specs/base.py @@ -68,7 +68,7 @@ from superset.sql_parse import ParsedQuery, Table from superset.superset_typing import ResultSetColumnType from superset.utils import core as utils -from superset.utils.core import ColumnSpec, GenericDataType, get_username +from superset.utils.core import ColumnSpec, GenericDataType from superset.utils.hashing import md5_sha_from_str from superset.utils.network import is_hostname_valid, is_port_open @@ -1393,7 +1393,6 @@ def process_statement(cls, statement: str, database: Database) -> str: if sql_query_mutator and not mutate_after_split: sql = sql_query_mutator( sql, - user_name=get_username(), # TODO(john-bodley): Deprecate in 3.0. security_manager=security_manager, database=database, ) diff --git a/superset/models/core.py b/superset/models/core.py index 43d12900e613d..1dbe698816a25 100755 --- a/superset/models/core.py +++ b/superset/models/core.py @@ -552,7 +552,6 @@ def get_df( # pylint: disable=too-many-locals ) -> pd.DataFrame: sqls = self.db_engine_spec.parse_sql(sql) engine = self._get_sqla_engine(schema) - username = utils.get_username() mutate_after_split = config["MUTATE_AFTER_SPLIT"] sql_query_mutator = config["SQL_QUERY_MUTATOR"] @@ -569,7 +568,6 @@ def _log_query(sql: str) -> None: engine.url, sql, schema, - get_username(), __name__, security_manager, ) @@ -580,7 +578,6 @@ def _log_query(sql: str) -> None: if mutate_after_split: sql_ = sql_query_mutator( sql_, - user_name=username, security_manager=security_manager, database=None, ) @@ -591,7 +588,6 @@ def _log_query(sql: str) -> None: if mutate_after_split: last_sql = sql_query_mutator( sqls[-1], - user_name=username, security_manager=security_manager, database=None, ) diff --git a/superset/models/helpers.py b/superset/models/helpers.py index 4022bcbc1373b..452acd81e6a58 100644 --- a/superset/models/helpers.py +++ b/superset/models/helpers.py @@ -884,7 +884,6 @@ def mutate_query_from_config(self, sql: str) -> str: if sql_query_mutator: sql = sql_query_mutator( sql, - user_name=utils.get_username(), # TODO(john-bodley): Deprecate in 3.0. security_manager=security_manager, database=self.database, ) diff --git a/superset/sql_lab.py b/superset/sql_lab.py index 149feb163926c..a2c4ae0bc3187 100644 --- a/superset/sql_lab.py +++ b/superset/sql_lab.py @@ -53,7 +53,6 @@ from superset.sqllab.limiting_factor import LimitingFactor from superset.utils.celery import session_scope from superset.utils.core import ( - get_username, json_iso_dttm_ser, override_user, QuerySource, @@ -256,7 +255,6 @@ def execute_sql_statement( # pylint: disable=too-many-arguments,too-many-statem # Hook to allow environment-specific mutation (usually comments) to the SQL sql = SQL_QUERY_MUTATOR( sql, - user_name=get_username(), # TODO(john-bodley): Deprecate in 3.0. security_manager=security_manager, database=database, ) @@ -267,7 +265,6 @@ def execute_sql_statement( # pylint: disable=too-many-arguments,too-many-statem query.database.sqlalchemy_uri, query.executed_sql, query.schema, - get_username(), __name__, security_manager, log_params, diff --git a/superset/sql_validators/presto_db.py b/superset/sql_validators/presto_db.py index 5bc844751b83b..78bd0f2186ad4 100644 --- a/superset/sql_validators/presto_db.py +++ b/superset/sql_validators/presto_db.py @@ -24,7 +24,7 @@ from superset.models.core import Database from superset.sql_parse import ParsedQuery from superset.sql_validators.base import BaseSQLValidator, SQLValidationAnnotation -from superset.utils.core import get_username, QuerySource +from superset.utils.core import QuerySource MAX_ERROR_ROWS = 10 @@ -58,7 +58,6 @@ def validate_statement( if sql_query_mutator: sql = sql_query_mutator( sql, - user_name=get_username(), # TODO(john-bodley): Deprecate in 3.0. security_manager=security_manager, database=database, )