villebro opened a new pull request, #30142: URL: https://github.com/apache/superset/pull/30142
### SUMMARY Currently the `from_dttm` and `to_dttm` Jinja variables make it possible to reference the time range endpoints from within the Jinja context. However, they have some shortcomings: - `to_dttm` always points to the current day, even if there's no time range present in the query (this appears to be a quirk of how the `get_since_until` helper function works). - They are always formatted using the `.isoformat()` method. This means that it's difficult to use them for database-specific formatting that's readily available in `BaseEngineSpec.convert_dttm`. - It's impossible to access a specific time filter if there are multiple time filters present. - Lastly, in the case of virtual datasets, it's not possible to remove the time filter from the outer query (this is possible for regular filter types using the `filter_value and `get_filters` macros). This PR adds a new Jinja macro called `get_time_filter`, which returns a dataclass with the following properties: - `since`: The start endpoint of the time range - `until`: The end of the time range - `time_range`: The (usually) human readable raw value of the time filter TODO: more to come ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF TODO: more to come ### TESTING INSTRUCTIONS <!--- Required! What steps can be taken to manually verify the changes? --> ### ADDITIONAL INFORMATION <!--- Check any relevant boxes with "x" --> <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue --> - [ ] Has associated issue: - [ ] Required feature flags: - [ ] 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]
