From 5426ca6aab69ad13064cd82831d71ac6706b00fc Mon Sep 17 00:00:00 2001 From: Daniel Gaspar Date: Fri, 9 Jun 2023 02:07:24 +0100 Subject: [PATCH 1/3] chore: remove deprecated api /superset/filter/... --- RESOURCES/STANDARD_ROLES.md | 1 - UPDATING.md | 1 + superset/views/core.py | 37 --------------------------- tests/integration_tests/core_tests.py | 13 ---------- 4 files changed, 1 insertion(+), 51 deletions(-) diff --git a/RESOURCES/STANDARD_ROLES.md b/RESOURCES/STANDARD_ROLES.md index ad67a681592a..593c36210109 100644 --- a/RESOURCES/STANDARD_ROLES.md +++ b/RESOURCES/STANDARD_ROLES.md @@ -105,7 +105,6 @@ |can queries on Superset|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O| |can stop query on Superset|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:| |can request access on Superset|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O| -|can filter on Superset|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O| |can dashboard on Superset|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O| |can results on Superset|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O| |can post on TableSchemaView|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O| diff --git a/UPDATING.md b/UPDATING.md index 70f7d5154d35..60a11dfe4ef2 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -24,6 +24,7 @@ assists people when migrating to a new version. ## Next +- [---](https://github.com/apache/superset/pull/---): Removed deprecated API `/superset/filter////` - [24185](https://github.com/apache/superset/pull/24185): `/api/v1/database/test_connection` and `api/v1/database/validate_parameters` permissions changed from `can_read` to `can_write`. Only Admin user's have access. - [24256](https://github.com/apache/superset/pull/24256): `Flask-Login` session validation is now set to `strong` by default. Previous setting was `basic`. - [24232](https://github.com/apache/superset/pull/24232): Enables ENABLE_TEMPLATE_REMOVE_FILTERS, DRILL_TO_DETAIL, DASHBOARD_CROSS_FILTERS by default, marks VERSIONED_EXPORT and ENABLE_TEMPLATE_REMOVE_FILTERS as deprecated. diff --git a/superset/views/core.py b/superset/views/core.py index 3b63eb74d81a..a2afec3ec52d 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -1016,43 +1016,6 @@ def explore( standalone_mode=standalone_mode, ) - @api - @handle_api_exception - @has_access_api - @event_logger.log_this - @expose("/filter////") - @deprecated( - new_target="/api/v1/datasource//" - "/column//values/" - ) - def filter( # pylint: disable=no-self-use - self, datasource_type: str, datasource_id: int, column: str - ) -> FlaskResponse: - """ - Endpoint to retrieve values for specified column. - - :param datasource_type: Type of datasource e.g. table - :param datasource_id: Datasource id - :param column: Column name to retrieve values for - :returns: The Flask response - :raises SupersetSecurityException: If the user cannot access the resource - """ - # TODO: Cache endpoint by user, datasource and column - datasource = DatasourceDAO.get_datasource( - db.session, DatasourceType(datasource_type), datasource_id - ) - if not datasource: - return json_error_response(DATASOURCE_MISSING_ERR) - - datasource.raise_for_access() - row_limit = apply_max_row_limit(config["FILTER_SELECT_ROW_LIMIT"]) - payload = json.dumps( - datasource.values_for_column(column_name=column, limit=row_limit), - default=utils.json_int_dttm_ser, - ignore_nan=True, - ) - return json_success(payload) - @staticmethod def save_or_overwrite_slice( # pylint: disable=too-many-arguments,too-many-locals diff --git a/tests/integration_tests/core_tests.py b/tests/integration_tests/core_tests.py index f0c72b068036..5189fa75fc20 100644 --- a/tests/integration_tests/core_tests.py +++ b/tests/integration_tests/core_tests.py @@ -320,19 +320,6 @@ def test_save_slice(self): db.session.delete(slc) db.session.commit() - @pytest.mark.usefixtures("load_energy_table_with_slice") - def test_filter_endpoint(self): - self.login(username="admin") - tbl_id = self.table_ids.get("energy_usage") - table = db.session.query(SqlaTable).filter(SqlaTable.id == tbl_id) - table.filter_select_enabled = True - url = "/superset/filter/table/{}/target/" - - # Changing name - resp = self.get_resp(url.format(tbl_id)) - assert len(resp) > 0 - assert "energy_target0" in resp - @pytest.mark.usefixtures("load_birth_names_dashboard_with_slices") def test_slice_data(self): # slice data should have some required attributes From 39d3a0328ac21a2ee4d99526a0eae508f5a02679 Mon Sep 17 00:00:00 2001 From: Daniel Gaspar Date: Fri, 9 Jun 2023 02:15:49 +0100 Subject: [PATCH 2/3] fix lint --- superset/views/core.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/superset/views/core.py b/superset/views/core.py index a2afec3ec52d..12f188c20f21 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -130,12 +130,7 @@ from superset.utils import core as utils, csv from superset.utils.async_query_manager import AsyncQueryTokenException from superset.utils.cache import etag_cache -from superset.utils.core import ( - apply_max_row_limit, - DatasourceType, - get_user_id, - ReservedUrlParameters, -) +from superset.utils.core import DatasourceType, get_user_id, ReservedUrlParameters from superset.utils.dates import now_as_float from superset.utils.decorators import check_dashboard_access from superset.views.base import ( From 989f1bb1a0dc36262931e4e886cd441a86738f87 Mon Sep 17 00:00:00 2001 From: Daniel Gaspar Date: Mon, 12 Jun 2023 08:37:18 +0100 Subject: [PATCH 3/3] fix docs on updating --- UPDATING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/UPDATING.md b/UPDATING.md index 60a11dfe4ef2..34ac15048ddf 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -24,7 +24,7 @@ assists people when migrating to a new version. ## Next -- [---](https://github.com/apache/superset/pull/---): Removed deprecated API `/superset/filter////` +- [24335](https://github.com/apache/superset/pull/24335): Removed deprecated API `/superset/filter////` - [24185](https://github.com/apache/superset/pull/24185): `/api/v1/database/test_connection` and `api/v1/database/validate_parameters` permissions changed from `can_read` to `can_write`. Only Admin user's have access. - [24256](https://github.com/apache/superset/pull/24256): `Flask-Login` session validation is now set to `strong` by default. Previous setting was `basic`. - [24232](https://github.com/apache/superset/pull/24232): Enables ENABLE_TEMPLATE_REMOVE_FILTERS, DRILL_TO_DETAIL, DASHBOARD_CROSS_FILTERS by default, marks VERSIONED_EXPORT and ENABLE_TEMPLATE_REMOVE_FILTERS as deprecated. @@ -34,6 +34,7 @@ assists people when migrating to a new version. ### Breaking Changes +- [24335](https://github.com/apache/superset/pull/24335): Removed deprecated API `/superset/filter////` - [23933](https://github.com/apache/superset/pull/23933) Removes the deprecated Multiple Line Charts. - [23741](https://github.com/apache/superset/pull/23741) Migrates the TreeMap chart and removes the legacy Treemap code. - [23712](https://github.com/apache/superset/pull/23712) Migrates the Pivot Table v1 chart to v2 and removes v1 code.