EBoisseauSierra opened a new issue, #19564: URL: https://github.com/apache/superset/issues/19564
When using [Jinja special variables](https://superset.apache.org/docs/installation/sql-templating/) in Custom SQL metrics (Explore Panel), `{{ from_dttm }}` and `{{ to_dttm }}` are not rendered — unlike, say, `{{ current_user_id() }}`. #### How to reproduce the bug Turn Jinja templating feature flag on: ```python FEATURE_FLAGS ={ "ENABLE_TEMPLATE_PROCESSING": True, } ``` 1. Go to your_dataset/BigNumber/Explore Panel 2. Click on Metric/Custom SQL 3. Use following definition: a. `MIN({{ current_user_id() }})` b. `MIN('{{ from_dttm }}')` ### Expected results Both definitions to return a number. ### Actual results * `MIN({{ current_user_id() }})` returns a result:  by executing the following query ```sql SELECT MIN(3) AS "MIN({{ current_user_id() }})" FROM my.db WHERE timestamp >= TO_TIMESTAMP('2022-03-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US') AND timestamp < TO_TIMESTAMP('2022-04-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US'); ``` * But `MIN('{{ from_dttm }}')` returns “No Data” (even with a Time Range filter set).  executing this query: ```sql SELECT MIN('{{ from_dttm }}') AS "MIN('{{ from_dttm }}')" FROM my.db WHERE timestamp >= TO_TIMESTAMP('2022-03-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US') AND timestamp < TO_TIMESTAMP('2022-04-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US'); ``` ### Environment (please complete the following information): - superset version: `1.4.1` (and also on https://c96e35bc.us2a.app.preset.io/ on 2022-04-06) - python version: `3.7.3` - any feature flags active: - ENABLE_TEMPLATE_PROCESSING ### Checklist Make sure to follow these steps before submitting your issue - thank you! - [x] I have checked the superset logs for python stacktraces and included it here as text if there are any. - [x] I have reproduced the issue with at least the latest released version of superset. - [x] I have checked the issue tracker for the same issue and I haven't found one similar. ### Additional context * Database engine: PostgreSQL * The only valid syntax for `{{ from_dttm }}` is using single quotes (i.e. `sum('{{ from_dttm }}')`). Indeed, both `{{ from_dttm }}` (no quotes) or `"{{ from_dttm }}"` (double quotes) yield an error. -- 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]
