dosubot[bot] commented on issue #38012:
URL: https://github.com/apache/superset/issues/38012#issuecomment-3908177644

   <!-- Answer -->
   This is a known issue that has been addressed through several PRs. The root 
cause is that [sqlglot attempts to parse unrendered Jinja templates as literal 
SQL](https://github.com/apache/superset/pull/36422), treating `{% if %}` syntax 
as invalid SQL rather than template syntax.
   
   **Recent fixes:**
   - [PR #36422](https://github.com/apache/superset/pull/36422) (merged Jan 
2026) - SQL validation now renders Jinja templates with provided 
`template_params` before validation
   - [PR #34802](https://github.com/apache/superset/pull/34802) - Fixed 
template parameters not being threaded through the SQL processing pipeline
   
   **If you're still seeing this on 6.0.0:**
   
   1. **Enable template processing** - Ensure `ENABLE_TEMPLATE_PROCESSING: 
True` is set in your [feature 
flags](https://github.com/apache/superset/discussions/37489)
   
   2. **Use defensive conditionals** for filter values that may be empty at 
save time:
      ```sql
      {% set filter_vals = filter_values('column_name') %}
      {% if filter_vals %}
        AND column_name IN {{ filter_vals | where_in }}
      {% endif %}
      ```
   
   3. **Check template_params** - Ensure 
[`template_params`](https://github.com/apache/superset/issues/34105) are being 
passed with your dataset save request
   
   The core issue is that during dataset save, [validation attempts to render 
templates without access to runtime 
values](https://github.com/apache/superset/issues/33579) (like `from_dttm`, 
filter values) that are only available during query execution. The fixes ensure 
templates are properly rendered with available context before sqlglot parsing.
   
   
   <!-- 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/281a34d5-fb6f-490d-bf1c-5d41e341083c?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/281a34d5-fb6f-490d-bf1c-5d41e341083c?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/281a34d5-fb6f-490d-bf1c-5d41e341083c?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/281a34d5-fb6f-490d-bf1c-5d41e341083c?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/281a34d5-fb6f-490d-bf1c-5d41e341083c?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/281a34d5-fb6f-490d-bf1c-5d41e341083c?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/281a34d5-fb6f-490d-bf1c-5d41e341083c?feedback_type=other)</sup>
   
   [![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20is%20a%20known%20issue%20that%20has%20been%20addressed%20through%20several%20PRs.%20The%20root%20cause%20is%20that%20%5Bsqlglot%20attempts%20to%20parse%20unrendered%20Jinja%20templates%20as%20literal%20SQL%5D%28https%3A//github.com/apache/superset/pull/36422%29%2C%20treating%20%60%7B%25%20if%20%25%7D%60%20syntax%20as%20invalid%20SQL%20rather%20than%20template%20syntax.%0A%0A%2A%2ARecent%20fixes%3A%2A%2A%0A-%20%5BPR%20%2336422%5D%28https%3A//github.com/apache/superset/pull/36422%29%20%28merged%20Jan%202026%29%20-%20SQL%20validation%20now%20renders%20Jinja%20templates%20with%20provided%20%60template_params%60%20before%20validation%0A-%20%5BPR%20%2334802%5D%28https%3A//github.com/apache/superset/pull/34802%29%20-%20Fixed%20template%20parameters
 
%20not%20being%20threaded%20through%20the%20SQL%20processing%20pipeline%0A%0A%2A%2AIf%20you%27re%20still%20seeing%20this%20on%206.0.0%3A%2A%2A%0A%0A1.%20%2A%2AEnable%20template%20processing%2A%2A%20-%20Ensure%20%60ENABLE_TEMPLATE_PROCESSING%3A%20True%60%20is%20set%20in%20your%20%5Bfeature%20flags%5D%28https%3A//github.com/apache/superset/discussions/37489%29%0A%0A2.%20%2A%2AUse%20defensive%20conditionals%2A%2A%20for%20filter%20values%20that%20may%20be%20empty%20at%20save%20time%3A%0A%20%20%20%60%60%60sql%0A%20%20%20%7B%25%20set%20filter_vals%20%3D%20filter_values%28%27column_name%27%29%20%25%7D%0A%20%20%20%7B%25%20if%20filter_vals%20%25%7D%0A%20%20%20%20%20AND%20column_name%20IN%20%7B%7B%20filter_vals%20%7C%20where_in%20%7D%7D%0A%20%20%20%7B%25%20endif%20%25%7D%0A%20%20%20%60%60%60%0A%0A3.%20%2A%2ACheck%20template_params%2A%2A%20-%20Ensure%20%5B%60template_params%60%5D%28https%3A//github.com/apache/superset/issues/34105%29%20are%20being%20passed%20with%20your%20dataset%20save%20requ
 
est%0A%0AThe%20core%20issue%20is%20that%20during%20dataset%20save%2C%20%5Bvalidation%20attempts%20to%20render%20templates%20without%20access%20to%20runtime%20values%5D%28https%3A//github.com/apache/superset/issues/33579%29%20%28like%20%60from_dttm%60%2C%20filter%20values%29%20that%20are%20only%20available%20during%20query%20execution.%20The%20fixes%20ensure%20templates%20are%20properly%20rendered%20with%20available%20context%20before%20sqlglot%20parsing.)&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/38012)


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to