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-unsubscr...@superset.apache.org

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


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

Reply via email to