You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "mikysetiawan (via GitHub)" <gi...@apache.org> on 2025/07/22 03:19:46 UTC

[I] Can't Use Jinja Templating on Filtering Chart [superset]

mikysetiawan opened a new issue, #34264:
URL: https://github.com/apache/superset/issues/34264

   ### Bug description
   
   After I update my apache superset to the newest version, I can't using Jinja Template on chart filter, it showing error 
   
   > Data error
   Invalid SQL clause: {% if true %} true {% endif %}
   
   but when I try it in SQL Lab, it's working
   
   before I update all my query is working well
   
   ### Screenshots/recordings
   
   **Screenshot when I try to use Jinja Template in chart filter**
   <img width="2439" height="1373" alt="Image" src="https://github.com/user-attachments/assets/df67d0b3-17ec-473b-a354-46923077f66a" />
   
   **Screenshot when I try in SQL Lab**
   
   <img width="2712" height="1299" alt="Image" src="https://github.com/user-attachments/assets/8da9d651-4ede-4e87-9064-91202c5b643b" />
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   3.9
   
   ### Node version
   
   16
   
   ### Browser
   
   Chrome
   
   ### 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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Can't Use Jinja Templating on Filtering Chart [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #34264:
URL: https://github.com/apache/superset/issues/34264#issuecomment-3100672297

   <!-- Greeting -->
   Hi @mikysetiawan! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the superset team.
   
   <!-- Answer -->
   Jinja templating is no longer supported in chart filter values in recent Superset versions. This is an intentional change for security and maintainability—filter values in charts are now treated as plain SQL values and are not processed through the Jinja engine, so using template syntax like `{% if ... %}` in a filter will cause a SQL error instead of being evaluated as a template. In contrast, SQL Lab still processes the entire query as a Jinja template, which is why it works there.
   
   If you need dynamic filtering with Jinja, you should include your template logic in the main SQL query or in virtual datasets, not in the filter value itself. For example, you can use Jinja in the SQL of a virtual dataset or in custom SQL expressions, and then use standard filter values in the chart controls. If you want to extend the Jinja context for supported places, you can use the `ENABLE_TEMPLATE_PROCESSING` feature flag and `JINJA_CONTEXT_ADDONS` in your `superset_config.py`, but this will not enable templating in chart filter values themselves. More details are in the [docs](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/docs/docs/configuration/sql-templating.mdx).
   
   If you need to implement conditional logic for filters, consider wrapping your logic in the main SQL using `CASE WHEN` or `if/else` blocks, as described in [this issue](https://github.com/apache/superset/issues/33591). This approach ensures your queries remain compatible with the current Superset behavior.
   
   
   <!-- Dosu Comment Footer -->
   *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
   
   ---
   <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/2085b963-cad0-4e94-8534-6e03b4287acb?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/2085b963-cad0-4e94-8534-6e03b4287acb?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/2085b963-cad0-4e94-8534-6e03b4287acb?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/2085b963-cad0-4e94-8534-6e03b4287acb?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/2085b963-cad0-4e94-8534-6e03b4287acb?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/2085b963-cad0-4e94-8534-6e03b4287acb?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/2085b963-cad0-4e94-8534-6e03b4287acb?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[!
 [Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/34264)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Can't Use Jinja Templating on Filtering Chart [superset]

Posted by "mikysetiawan (via GitHub)" <gi...@apache.org>.
mikysetiawan commented on issue #34264:
URL: https://github.com/apache/superset/issues/34264#issuecomment-3100930968

   thanks! 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Can't Use Jinja Templating on Filtering Chart [superset]

Posted by "mikysetiawan (via GitHub)" <gi...@apache.org>.
mikysetiawan closed issue #34264: Can't Use Jinja Templating on Filtering Chart
URL: https://github.com/apache/superset/issues/34264


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org