giftig opened a new pull request, #25950: URL: https://github.com/apache/superset/pull/25950
### SUMMARY <!--- Describe the change below, including rationale and design decisions --> Pass from_dttm and to_dttm as additional context to the dataset macro, allowing any jinja templating in the underlying dataset query text to refer to this context. This is useful in situations where virtual dataset A incorporates from_dttm and/or to_dttm into the query, in order to make the underlying query aware of chart filter contexts, and then virtual dataset B is built on top of dataset A and used in charts. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF <!--- Skip this if not applicable --> #### Before  #### After  ### TESTING INSTRUCTIONS <!--- Required! What steps can be taken to manually verify the changes? --> Make sure `ENABLE_TEMPLATE_PROCESSING` is turned on, and use a standard dev superset environment with the samples database available. You can also tweak these steps to use other data or backends as long as you apply a time filter in your dashboard. 1. Using the samples database, run the following query in SQL Lab: ```sql SELECT ds, gender, name, num_boys, num_girls, '{{ from_dttm or "empty" }}' from_dttm FROM public.birth_names ``` and save it as a virtual dataset called `from_dttm`. Currently the `from_dttm` field will show `empty` because it won't be populated until a filter is applied on a chart in a later step. 2. Create a table chart from this dataset, select all fields, and add a time filter on `ds`. Add this chart to a new dashboard, and configure a time filter for `ds` on that dashboard. Set that filter to the past 30 years so we can see some data. Notice that now `from_dttm` displays a datetime value. 3. In SQL Lab again, run the following query: ```sql SELECT * FROM {{ dataset(25) }}; ``` you'll need to make sure `25` here is the ID of your virtual dataset `from_dttm` in step 1. Create a chart exactly like the first one, and add it to the same dashboard so you can see the two charts side by side. 4. Compare the two tables and you will see `from_dttm` is correctly populated in both charts; prior to this change the second one, using the `dataset` macro, will show `empty` instead as it does not propagate sufficient context from the chart through the macro. ### ADDITIONAL INFORMATION <!--- Check any relevant boxes with "x" --> <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue --> - [ ] Has associated issue: - [x] Required feature flags: `ENABLE_TEMPLATE_PROCESSING` - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [ ] Introduces new feature or API - [ ] Removes existing feature or API -- 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]
