diff --git a/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.test.tsx b/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.test.tsx index faa38b02b1ebe..07f347b143d44 100644 --- a/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.test.tsx +++ b/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.test.tsx @@ -55,7 +55,7 @@ describe('TimezoneSelector', () => { expect(select).toBeInTheDocument(); userEvent.click(select); const selection = await screen.findByTitle( - 'GMT -06:00 (Mountain Daylight Time)', + 'GMT -10:00 (Hawaii Standard Time)', ); expect(selection).toBeInTheDocument(); userEvent.click(selection); diff --git a/superset/charts/api.py b/superset/charts/api.py index 6ebcad4c97f66..5faeb431d7723 100644 --- a/superset/charts/api.py +++ b/superset/charts/api.py @@ -52,13 +52,13 @@ from superset.charts.commands.importers.dispatcher import ImportChartsCommand from superset.charts.commands.update import UpdateChartCommand from superset.charts.dao import ChartDAO -from superset.charts.post_processing import apply_post_process from superset.charts.filters import ( ChartAllTextFilter, ChartCertifiedFilter, ChartFavoriteFilter, ChartFilter, ) +from superset.charts.post_processing import apply_post_process from superset.charts.schemas import ( CHART_SCHEMAS, ChartPostSchema, diff --git a/superset/common/query_object.py b/superset/common/query_object.py index 6ef00cdb835b6..e05cad7d6080c 100644 --- a/superset/common/query_object.py +++ b/superset/common/query_object.py @@ -25,8 +25,6 @@ from superset import app, db from superset.connectors.base.models import BaseDatasource from superset.connectors.connector_registry import ConnectorRegistry -from superset.exceptions import QueryObjectValidationError -from superset.typing import Metric, OrderBy from superset.exceptions import ( QueryClauseValidationException, QueryObjectValidationError, diff --git a/superset/config.py b/superset/config.py index 54545dfda89fd..7f504582c5920 100644 --- a/superset/config.py +++ b/superset/config.py @@ -38,7 +38,6 @@ from flask import Blueprint from flask_appbuilder.security.manager import AUTH_DB from pandas.io.parsers import STR_NA_VALUES -from typing_extensions import Literal from werkzeug.local import LocalProxy from superset.jinja_context import BaseTemplateProcessor diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py index 85e41a4b6796a..6495f305891c9 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -1452,7 +1452,9 @@ def _get_top_groups( # string into a timestamp. if column_map[dimension].is_temporal and isinstance(value, str): dttm = dateutil.parser.parse(value) - value = text(self.db_engine_spec.convert_dttm("TIMESTAMP", dttm)) + value = text( + str(self.db_engine_spec.convert_dttm("TIMESTAMP", dttm)) + ) group.append(groupby_exprs[dimension] == value) groups.append(and_(*group)) diff --git a/superset/db_engine_specs/postgres.py b/superset/db_engine_specs/postgres.py index 47cf874ccbc59..2e1f2908c15f8 100644 --- a/superset/db_engine_specs/postgres.py +++ b/superset/db_engine_specs/postgres.py @@ -32,7 +32,7 @@ ) from flask_babel import gettext as __ -from pytz import _FixedOffset # type: ignore +from pytz import _FixedOffset from sqlalchemy.dialects.postgresql import ARRAY, DOUBLE_PRECISION, ENUM, JSON from sqlalchemy.dialects.postgresql.base import PGInspector from sqlalchemy.types import String, TypeEngine diff --git a/superset/utils/async_query_manager.py b/superset/utils/async_query_manager.py index 14f89a83a109b..b197a853cd9c6 100644 --- a/superset/utils/async_query_manager.py +++ b/superset/utils/async_query_manager.py @@ -199,9 +199,5 @@ def update_job( logger.debug("********** logging event data to stream %s", scoped_stream_name) logger.debug(event_data) - self._redis.xadd( # type: ignore - scoped_stream_name, event_data, "*", self._stream_limit - ) - self._redis.xadd( # type: ignore - full_stream_name, event_data, "*", self._stream_limit_firehose - ) + self._redis.xadd(scoped_stream_name, event_data, "*", self._stream_limit) + self._redis.xadd(full_stream_name, event_data, "*", self._stream_limit_firehose) diff --git a/tests/integration_tests/charts/api_tests.py b/tests/integration_tests/charts/api_tests.py index 251f4068d2333..32d6f65e41b16 100644 --- a/tests/integration_tests/charts/api_tests.py +++ b/tests/integration_tests/charts/api_tests.py @@ -2179,5 +2179,3 @@ def test_chart_data_virtual_table_with_colons(self): assert "':asdf'" in result["query"] assert "':xyz:qwerty'" in result["query"] assert "':qwerty:'" in result["query"] - - diff --git a/tests/unit_tests/sql_parse_tests.py b/tests/unit_tests/sql_parse_tests.py index 63dfeeef15ac4..36ab75df85146 100644 --- a/tests/unit_tests/sql_parse_tests.py +++ b/tests/unit_tests/sql_parse_tests.py @@ -15,8 +15,8 @@ # specific language governing permissions and limitations # under the License. -from superset.sql_parse import ParsedQuery - +import unittest +from typing import Set import pytest import sqlparse @@ -535,22 +535,6 @@ def test_extract_tables_multistatement() -> None: } -def test_extract_tables_keyword() -> None: - """ - Test that table names that are keywords work as expected. - - If the table name is a ``sqlparse`` reserved keyword (eg, "table_name") the parser - needs extra logic to identify it. - """ - assert extract_tables("SELECT * FROM table_name") == {Table("table_name")} - assert extract_tables("SELECT * FROM table_name AS foo") == {Table("table_name")} - - # these 3 are considered keywords - assert extract_tables("SELECT * FROM catalog_name.schema_name.table_name") == { - Table("table_name", "schema_name", "catalog_name") - } - - def test_extract_tables_complex() -> None: """ Test a few complex queries. @@ -995,46 +979,6 @@ def test_is_select_cte_with_comments() -> None: assert sql.is_select() -def test_cte_is_select() -> None: - """ - Some CTEs are not correctly identified as SELECTS. - """ - # `AS(` gets parsed as a function - sql = ParsedQuery( - """WITH foo AS( -SELECT - FLOOR(__time TO WEEK) AS "week", - name, - COUNT(DISTINCT user_id) AS "unique_users" -FROM "druid"."my_table" -GROUP BY 1,2 -) -SELECT - f.week, - f.name, - f.unique_users -FROM foo f""" - ) - assert sql.is_select() - - -def test_unknown_select() -> None: - """ - Test that `is_select` works when sqlparse fails to identify the type. - """ - sql = "WITH foo AS(SELECT 1) SELECT 1" - assert sqlparse.parse(sql)[0].get_type() == "UNKNOWN" - assert ParsedQuery(sql).is_select() - - sql = "WITH foo AS(SELECT 1) INSERT INTO my_table (a) VALUES (1)" - assert sqlparse.parse(sql)[0].get_type() == "UNKNOWN" - assert not ParsedQuery(sql).is_select() - - sql = "WITH foo AS(SELECT 1) DELETE FROM my_table" - assert sqlparse.parse(sql)[0].get_type() == "UNKNOWN" - assert not ParsedQuery(sql).is_select() - - def test_get_query_with_new_limit_comment() -> None: """ Test that limit is applied correctly.