diff --git a/superset/sql_parse.py b/superset/sql_parse.py index 62a2457171ede..3f4daf171a9ad 100644 --- a/superset/sql_parse.py +++ b/superset/sql_parse.py @@ -1093,7 +1093,7 @@ def extract_tables_from_jinja_sql(sql: str, database: Database) -> set[Table]: tables.add( Table( *[ - remove_quotes(part) + remove_quotes(part.strip()) for part in node.args[0].value.split(".")[::-1] if len(node.args) == 1 ] diff --git a/tests/unit_tests/sql_parse_tests.py b/tests/unit_tests/sql_parse_tests.py index dab5dbf9c709c..9cf049418142f 100644 --- a/tests/unit_tests/sql_parse_tests.py +++ b/tests/unit_tests/sql_parse_tests.py @@ -1890,6 +1890,7 @@ def test_is_select() -> None: "macro", [ "latest_partition('foo.bar')", + "latest_partition(' foo.bar ')", # Non-atypical user error which works "latest_sub_partition('foo.bar', baz='qux')", ], )