This is an automated email from the ASF dual-hosted git repository. michaelsmolina pushed a commit to branch 3.1 in repository https://gitbox.apache.org/repos/asf/superset.git
commit 58a53b445752ec51038e4f9d2b21fbebed297621 Author: John Bodley <[email protected]> AuthorDate: Tue Apr 2 17:08:42 2024 -0700 chore(sql_parse): Strip leading/trailing whitespace in Jinja macro extraction (#27842) (cherry picked from commit 5ab95aaf7d405d974fe441a7af7855a9f9d0467d) --- superset/sql_parse.py | 2 +- tests/unit_tests/sql_parse_tests.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/superset/sql_parse.py b/superset/sql_parse.py index 62a2457171..3f4daf171a 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 1d4f4088cd..20f1823218 100644 --- a/tests/unit_tests/sql_parse_tests.py +++ b/tests/unit_tests/sql_parse_tests.py @@ -1891,6 +1891,7 @@ SELECT * FROM t""" "macro", [ "latest_partition('foo.bar')", + "latest_partition(' foo.bar ')", # Non-atypical user error which works "latest_sub_partition('foo.bar', baz='qux')", ], )
