This is an automated email from the ASF dual-hosted git repository.

johnbodley pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 5ab95aaf7d chore(sql_parse): Strip leading/trailing whitespace in 
Jinja macro extraction (#27842)
5ab95aaf7d is described below

commit 5ab95aaf7d405d974fe441a7af7855a9f9d0467d
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)
---
 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 2fab2c26fb..30083e484a 100644
--- a/superset/sql_parse.py
+++ b/superset/sql_parse.py
@@ -1548,7 +1548,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 eae43dd4c3..d10c9dbe25 100644
--- a/tests/unit_tests/sql_parse_tests.py
+++ b/tests/unit_tests/sql_parse_tests.py
@@ -1937,6 +1937,7 @@ def test_sqlstatement() -> None:
     "macro",
     [
         "latest_partition('foo.bar')",
+        "latest_partition(' foo.bar ')",  # Non-atypical user error which works
         "latest_sub_partition('foo.bar', baz='qux')",
     ],
 )

Reply via email to