diff --git a/superset/db_engine_specs/teradata.py b/superset/db_engine_specs/teradata.py index eb719560faf20..8e7589980b15b 100644 --- a/superset/db_engine_specs/teradata.py +++ b/superset/db_engine_specs/teradata.py @@ -153,7 +153,9 @@ def _get_table(tlist: TokenList) -> Optional[Table]: tokens = tlist.tokens[:idx] odd_token_number = len(tokens) in (1, 3, 5) - qualified_name_parts = all(imt(token, t=[Name, String]) for token in tokens[::2]) + qualified_name_parts = all( + imt(token, t=[Name, String]) for token in tokens[::2] + ) dot_separators = all(imt(token, m=(Punctuation, ".")) for token in tokens[1::2]) if odd_token_number and qualified_name_parts and dot_separators: return Table(*[remove_quotes(token.value) for token in tokens[::-2]]) diff --git a/tests/unit_tests/db_engine_specs/test_teradata.py b/tests/unit_tests/db_engine_specs/test_teradata.py index a2affcc83846c..8d9fc08c4a631 100644 --- a/tests/unit_tests/db_engine_specs/test_teradata.py +++ b/tests/unit_tests/db_engine_specs/test_teradata.py @@ -15,20 +15,18 @@ # specific language governing permissions and limitations # under the License. # pylint: disable=unused-argument, import-outside-toplevel, protected-access -from datetime import datetime -import pytest from flask.ctx import AppContext -def test_ParsedQuery_tds_lower_limit(app_context: AppContext) -> None: +def test_ParsedQueryTeradata_lower_limit(app_context: AppContext) -> None: """ - Test the custom ``ParsedQuery_td`` that calls ``_extract_limit_from_query_td(`` + Test the custom ``ParsedQueryTeradata`` that calls ``_extract_limit_from_query_td(`` The CLass looks for Teradata limit keywords TOP and SAMPLE vs LIMIT in - other dialects. and + other dialects. """ - from superset.db_engine_specs.teradata import TeradataEngineSpec, ParsedQueryTeradata + from superset.db_engine_specs.teradata import TeradataEngineSpec sql = "SEL TOP 1000 * FROM My_table;" limit = 100 @@ -38,8 +36,14 @@ def test_ParsedQuery_tds_lower_limit(app_context: AppContext) -> None: ) -def test_ParsedQuery_tds_higher_limit(app_context: AppContext) -> None: - from superset.db_engine_specs.teradata import TeradataEngineSpec, ParsedQueryTeradata +def test_ParsedQueryTeradata_higher_limit(app_context: AppContext) -> None: + """ + Test the custom ``ParsedQueryTeradata`` that calls ``_extract_limit_from_query_td(`` + + The CLass looks for Teradata limit keywords TOP and SAMPLE vs LIMIT in + other dialects. + """ + from superset.db_engine_specs.teradata import TeradataEngineSpec sql = "SEL TOP 1000 * FROM My_table;" limit = 10000 @@ -49,14 +53,14 @@ def test_ParsedQuery_tds_higher_limit(app_context: AppContext) -> None: ) -def test_ParsedQuery_tds_equal_limit(app_context: AppContext) -> None: +def test_ParsedQueryTeradata_equal_limit(app_context: AppContext) -> None: """ - Test the custom ``ParsedQuery_td`` that calls ``_extract_limit_from_query_td(`` + Test the custom ``ParsedQueryTeradata`` that calls ``_extract_limit_from_query_td(`` The CLass looks for Teradata limit keywords TOP and SAMPLE vs LIMIT in - other dialects. and + other dialects. """ - from superset.db_engine_specs.teradata import TeradataEngineSpec, ParsedQueryTeradata + from superset.db_engine_specs.teradata import TeradataEngineSpec sql = "SEL TOP 1000 * FROM My_table;" limit = 1000 @@ -66,14 +70,14 @@ def test_ParsedQuery_tds_equal_limit(app_context: AppContext) -> None: ) -def test_ParsedQuery_tds_no_limit(app_context: AppContext) -> None: +def test_ParsedQueryTeradata_no_limit(app_context: AppContext) -> None: """ - Test the custom ``ParsedQuery_td`` that calls ``_extract_limit_from_query_td(`` + Test the custom ``ParsedQueryTeradata`` that calls ``_extract_limit_from_query_td(`` The CLass looks for Teradata limit keywords TOP and SAMPLE vs LIMIT in - other dialects. and + other dialects. """ - from superset.db_engine_specs.teradata import TeradataEngineSpec, ParsedQueryTeradata + from superset.db_engine_specs.teradata import TeradataEngineSpec sql = "SEL * FROM My_table;" limit = 1000