Bug description
Perform the same steps as outlined in Cannot save a query with Parameters as a Dataset (Jinja template default values). SQL query cannot be saved as a dataset (i get a fatal error message). From what i understand, this was fixed, with the ability to set a checkbox option to include the template parameter as part of the virtual dataset ? I DO NOT see this in the dialogue that appears when saving the dataset.
Screenshots/recordings
No response
Superset version
5.0.0
Python version
3.9
Node version
16
Browser
Not applicable
Additional context
No response
Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [ ] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Comment From: dosubot[bot]
Hi @Auburg! I'm Dosu and I’m helping the superset team.
The ability to save a query with Jinja template parameters as a dataset is available in Superset 5.0.0, but the checkbox to "Include Template Parameters" only appears if the ENABLE_TEMPLATE_PROCESSING feature flag is enabled in your superset_config.py. By default, this flag is off, so you won't see the checkbox or be able to save Jinja-parameterized datasets unless an admin enables it. You can find more details in the docs and see the relevant frontend logic here.
If you enable ENABLE_TEMPLATE_PROCESSING and still don't see the checkbox, there may be a config or caching issue. Let me know if that's the case or if you need help with the config.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
Comment From: Auburg
@dosu i believe i have ENABLE_TEMPLATE_PROCESSING set because i am able to set JINJA params in the UI and my SQL query works in SQL Query lab ? Here's a screenshot of my query working using that param:
It's just that saving this as a dataset results in an error
Comment From: dosubot[bot]
You can use Jinja parameters in SQL Lab because they're injected at query execution time, but saving a query as a dataset with Jinja parameters requires a few extra things: the ENABLE_TEMPLATE_PROCESSING flag must be enabled, and you must check the "Include Template Parameters" box in the Save Dataset dialog. If you don't see this checkbox, it could be a frontend cache/config issue—try a hard refresh or restarting Superset to ensure the flag is recognized in the UI. If you do see the checkbox and still get an error, the most common causes are malformed template parameters (invalid JSON), or issues with how Superset handles Jinja context during dataset validation and permission checks (especially if your SQL can render to an empty or invalid statement) source.
Could you confirm if the checkbox appears for you, and if so, whether you checked it when saving? Also, if you can share the exact error message or stack trace from the UI or logs, that would help pinpoint the issue. In the meantime, double-check that your template parameters are valid JSON, and consider using if/else logic in your SQL to avoid empty results when filters are missing source.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
Comment From: Auburg
Hi - i did a hard refresh but still didn't see that option - here's a screenshot of the dialog box that appears when saving to a dataset:
as you can see, the "Include Template Parameters" option isn't visible. Am i right in assuming that if i'm able to set JINJA params in the UI then that should also mean i should see that option (i.e. they both use the ENABLE_TEMPLATE_PROCESSING setting) ? As a side note, including if/else logic in the SQL isn't really practical for our use case because of the complexity of the SQL
Comment From: Auburg
Here's a log of the error when i save:
`2025-07-08 14:56:57,112:INFO:werkzeug:10.5.0.1 - - [08/Jul/2025 14:56:57] "GET /api/v1/me/ HTTP/1.1" 200 -
2025-07-08 14:57:11,546:DEBUG:superset.stats_logger:[stats_logger] (incr) DatasetRestApi.post.warning
2025-07-08 14:57:11,547:ERROR:flask_appbuilder.api:Error parsing near '{' at line 3:6
Traceback (most recent call last):
File "/app/superset/sql/parse.py", line 267, in parse
return sqlglot.parse(script, dialect=dialect)
File "/app/.venv/lib/python3.10/site-packages/sqlglot/__init__.py", line 102, in parse
return Dialect.get_or_raise(read or dialect).parse(sql, opts)
File "/app/.venv/lib/python3.10/site-packages/sqlglot/dialects/dialect.py", line 991, in parse
return self.parser(opts).parse(self.tokenize(sql), sql)
File "/app/.venv/lib/python3.10/site-packages/sqlglot/parser.py", line 1507, in parse
return self._parse(
File "/app/.venv/lib/python3.10/site-packages/sqlglot/parser.py", line 1576, in _parse
expressions.append(parse_method(self))
File "/app/.venv/lib/python3.10/site-packages/sqlglot/parser.py", line 1817, in _parse_statement
expression = self._parse_set_operations(expression) if expression else self._parse_select()
File "/app/.venv/lib/python3.10/site-packages/sqlglot/parser.py", line 3136, in _parse_select
from = self._parse_from()
File "/app/.venv/lib/python3.10/site-packages/sqlglot/parser.py", line 3445, in _parse_from
exp.From, comments=self._prev_comments, this=self._parse_table(joins=joins)
File "/app/.venv/lib/python3.10/site-packages/sqlglot/parser.py", line 3899, in _parse_table
self._parse_table_parts(schema=schema, is_db_reference=is_db_reference)
File "/app/.venv/lib/python3.10/site-packages/sqlglot/parser.py", line 3831, in _parse_table_parts
self.raise_error(f"Expected table name but got {self._curr}")
File "/app/.venv/lib/python3.10/site-packages/sqlglot/parser.py", line 1620, in raise_error
raise error
�sqlglot.errors.ParseError: Expected table name but got
SELECT * FROM {{ param1 }}
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/app/.venv/lib/python3.10/site-packages/flask_appbuilder/api/init.py", line 111, in wraps return f(self, args, kwargs) File "/app/superset/views/base_api.py", line 120, in wraps duration, response = time_function(f, self, args, kwargs) File "/app/superset/utils/core.py", line 1369, in time_function response = func(*args, kwargs) File "/app/superset/utils/log.py", line 304, in wrapper value = f(args, kwargs) File "/app/superset/views/base_api.py", line 92, in wraps return f(self, args, kwargs) File "/app/superset/datasets/api.py", line 349, in post new_model = CreateDatasetCommand(item).run() File "/app/superset/utils/decorators.py", line 266, in wrapped return on_error(ex) File "/app/superset/utils/decorators.py", line 236, in on_error raise ex File "/app/superset/utils/decorators.py", line 259, in wrapped result = func(*args, kwargs) File "/app/superset/commands/dataset/create.py", line 51, in run dataset.fetch_metadata() File "/app/superset/connectors/sqla/models.py", line 1801, in fetch_metadata new_columns = self.external_metadata() File "/app/superset/connectors/sqla/models.py", line 1381, in external_metadata return get_virtual_table_metadata(dataset=self) File "/app/superset/connectors/sqla/utils.py", line 109, in get_virtual_table_metadata parsed_script = SQLScript(sql, engine=db_engine_spec.engine) File "/app/superset/sql/parse.py", line 670, in init self.statements = statement_class.split_script(script, engine) File "/app/superset/sql/parse.py", line 294, in split_script for ast in cls._parse(script, engine) File "/app/superset/sql/parse.py", line 270, in _parse raise SupersetParseError( superset.exceptions.SupersetParseError: Error parsing near '{' at line 3:6 2025-07-08 14:57:11,547:INFO:werkzeug:10.5.0.1 - - [08/Jul/2025 14:57:11] "POST /api/v1/dataset/ HTTP/1.1" 500 -`