You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "dosubot[bot] (via GitHub)" <gi...@apache.org> on 2026/05/02 02:59:45 UTC
Re: [D] The SQL can be executed correctly, but fails to be saved as a dataset. [superset]
GitHub user dosubot[bot] edited a comment on the discussion: The SQL can be executed correctly, but fails to be saved as a dataset.
<!-- Answer -->
The error happens because, during dataset creation, Superset doesn't have access to runtime filter values—so your Jinja template's filter_values calls return empty lists. When you use where_in on an empty list, it generates SQL like AND is_apply IN (), which is invalid and causes the syntax error you see. This is different from SQL Lab, where you can provide test filter values and the query works as expected.
To fix this, update your Jinja template to only include the IN clause if filter_values returns a non-empty list. For example:
```sql
{% set is_apply_values = filter_values('is_apply') %}
{% if is_apply_values %}
and is_apply in {{ is_apply_values | where_in }}
{% endif %}
```
Repeat this pattern for each filter. This way, if no filter values are present, the IN clause is omitted and you avoid generating invalid SQL. You can find more details and examples in the official Superset docs on [SQL templating](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/docs/docs/configuration/sql-templating.mdx).
Recent Superset versions have improved error reporting for template issues, but template authors still need to guard against empty filter values to prevent errors like this one.
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).*
---
Share context across your team and agents. Try [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fsuperset).
[](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fsuperset&message_id=b7a0a32b-bb53-449c-ae91-ce44a1106a0c) [](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fsuperset) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fsuperset)
GitHub link: https://github.com/apache/superset/discussions/35171#discussioncomment-14426949
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org