diff --git a/superset/sql_parse.py b/superset/sql_parse.py index c8316dd6cc2..21a99e716e2 100644 --- a/superset/sql_parse.py +++ b/superset/sql_parse.py @@ -1559,7 +1559,7 @@ def extract_tables_from_jinja_sql(sql: str, database: Database) -> set[Table]: Table( *[ remove_quotes(part.strip()) - for part in node.args[0].value.split(".")[::-1] + for part in node.args[0].as_const().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 593085c4ea5..ac24e05979b 100644 --- a/tests/unit_tests/sql_parse_tests.py +++ b/tests/unit_tests/sql_parse_tests.py @@ -1942,6 +1942,7 @@ def test_sqlstatement() -> None: [ "latest_partition('foo.bar')", "latest_partition(' foo.bar ')", # Non-atypical user error which works + "latest_partition('foo.%s'|format('bar'))", "latest_sub_partition('foo.bar', baz='qux')", ], )