You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/04/06 13:37:56 UTC

[GitHub] [superset] EBoisseauSierra opened a new issue, #19564: {{ from_dttm }} and {{ to_dttm }} Jinja special variables are not rendered in Custom SQL metrics

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:
   
   ![Screenshot from 2022-04-06 14-31-25_shadow](https://user-images.githubusercontent.com/37387755/161986495-c5ad557d-7e69-4da6-8f8c-b720f821c10d.png)
   
   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).
   
   ![Screenshot from 2022-04-06 14-31-04_shadow](https://user-images.githubusercontent.com/37387755/161986525-9cdac00c-08c1-4983-833e-59cd3b28a675.png)
   
   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: notifications-unsubscribe@superset.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] villebro closed issue #19564: `{{ from_dttm }}` and `{{ to_dttm }}` Jinja special variables are not rendered in Custom SQL metrics

Posted by GitBox <gi...@apache.org>.
villebro closed issue #19564: `{{ from_dttm }}` and `{{ to_dttm }}` Jinja special variables are not rendered in Custom SQL metrics
URL: https://github.com/apache/superset/issues/19564


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org