rusackas opened a new pull request, #36544:
URL: https://github.com/apache/superset/pull/36544

   ## SUMMARY
   
   This PR addresses a long-standing source of confusion documented in #21793: 
users attempting to use `{{ from_dttm }}` and `{{ to_dttm }}` Jinja variables 
directly in SQL Lab queries receive "undefined parameter" errors.
   
   **Root cause**: These variables are only populated when a chart or dashboard 
provides a time range filter context. They are NOT available in standalone SQL 
Lab queries.
   
   ### Changes
   
   1. **Updated variable descriptions** to explicitly note context requirements
   2. **Added "Understanding Context Availability" section** explaining:
      - When these variables are populated (Explore/Chart views, dashboard 
filters)
      - Why they fail in standalone SQL Lab queries
   3. **Documented three workarounds** for testing in SQL Lab:
      - Using Jinja `default` filter (recommended)
      - Using SQL Lab Parameters
      - Using `{% set %}` for testing
   4. **Added tip** about filter values overriding defaults when used in charts
   
   ## BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A - documentation only
   
   ## TESTING INSTRUCTIONS
   
   1. Review the updated docs at `docs/docs/configuration/sql-templating.mdx`
   2. Verify the explanations are clear and accurate
   3. Optionally test the workarounds in a local Superset instance
   
   ## ADDITIONAL INFORMATION
   
   - Fixes #21793 (3+ year old issue)
   - This was identified through code analysis of `superset/jinja_context.py` 
and `superset/models/helpers.py`
   - The `from_dttm`/`to_dttm` variables are deprecated in favor of 
`get_time_filter()` starting in v5.0
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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