You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2024/12/06 19:51:01 UTC
(superset) branch fix-sql-parsing-template created (now 2aa07b8656)
This is an automated email from the ASF dual-hosted git repository.
beto pushed a change to branch fix-sql-parsing-template
in repository https://gitbox.apache.org/repos/asf/superset.git
at 2aa07b8656 fix: pass string to process_template
This branch includes the following new commits:
new 2aa07b8656 fix: pass string to process_template
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(superset) 01/01: fix: pass string to process_template
Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch fix-sql-parsing-template
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 2aa07b8656c429201984e2d89bcd9d916df46dd6
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Fri Dec 6 14:50:47 2024 -0500
fix: pass string to process_template
---
superset/sql_parse.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/superset/sql_parse.py b/superset/sql_parse.py
index cb457cd4f5..377f09ec35 100644
--- a/superset/sql_parse.py
+++ b/superset/sql_parse.py
@@ -26,7 +26,7 @@ from typing import Any, cast, TYPE_CHECKING
import sqlparse
from flask_babel import gettext as __
-from jinja2 import nodes
+from jinja2 import nodes, Template
from sqlalchemy import and_
from sqlparse import keywords
from sqlparse.lexer import Lexer
@@ -999,10 +999,13 @@ def extract_tables_from_jinja_sql(sql: str, database: Database) -> set[Table]:
node.fields = nodes.TemplateData.fields
node.data = "NULL"
+ # re-render template back into a string
+ rendered_template = Template(template).render()
+
return (
tables
| ParsedQuery(
- sql_statement=processor.process_template(template),
+ sql_statement=processor.process_template(rendered_template),
engine=database.db_engine_spec.engine,
).tables
)