This is an automated email from the ASF dual-hosted git repository. michaelsmolina pushed a commit to branch 5.0 in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/5.0 by this push: new 5eb61ec1b6 fix: extract tables from jinja (#34307) 5eb61ec1b6 is described below commit 5eb61ec1b69edb85a2d4e0173be74806ca7efb42 Author: JUST.in DO IT <justin.p...@airbnb.com> AuthorDate: Fri Jul 25 05:06:15 2025 -0700 fix: extract tables from jinja (#34307) --- superset/sql_parse.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/superset/sql_parse.py b/superset/sql_parse.py index e82e88ea75..0e4aa63757 100644 --- a/superset/sql_parse.py +++ b/superset/sql_parse.py @@ -943,11 +943,11 @@ def extract_tables_from_jinja_sql(sql: str, database: Database) -> set[Table]: ) processor = get_template_processor(database) - template = processor.env.parse(sql) + ast = processor.env.parse(sql) tables = set() - for node in template.find_all(nodes.Call): + for node in ast.find_all(nodes.Call): if isinstance(node.node, nodes.Getattr) and node.node.attr in ( "latest_partition", "latest_sub_partition", @@ -972,7 +972,9 @@ def extract_tables_from_jinja_sql(sql: str, database: Database) -> set[Table]: node.data = "NULL" # re-render template back into a string - rendered_sql = Template(template).render(processor.get_context()) + code = processor.env.compile(ast) + template = Template.from_code(processor.env, code, globals=processor.env.globals) + rendered_sql = template.render(processor.get_context()) return ( tables