cbuffevant opened a new issue, #22261:
URL: https://github.com/apache/superset/issues/22261

   Templates used in dataset metrics are not being render at all when used in 
charts.
   
   #### How to reproduce the bug
   
   I was able to replicate the issue running Superset locally followint this 
instructions 
https://superset.apache.org/docs/installation/installing-superset-using-docker-compose.
   
   1. Go to Datasets
   2. Open `flights` dataset
   3. Create a new metric with this information
    
   > name: my_metric
   > label: My Metric
   > SQL: sum(case when '{{ time_grain}}' = 'P1W' then 1 when '{{ time_grain}}' 
= 'P1D' then -1 else 0 end)
   
   4. Save the dataset
   5. Go to create a new Chart (for example, Time Series bar chart, v2)
   6. Select `flights` dataset
   7. Drop `My Metric` into the Metric section of the chart
   8. Update the chart.
   9. Create a new adhoc metric with the same SQL code than the dataset metric.
   10. Update the chart.
   
   ### Expected results
   Both metrics should display the same information.
   
   ### Actual results
   The dataset metrics is set to 0 while the ad hoc metric has the right values.
   If you go to check the actual query, you will see that the template `{{ 
time_grain }}` is not rendered in the dataset metric case.
   
   #### Screenshots
   
![image](https://user-images.githubusercontent.com/8312839/204580212-cccf3dff-e6df-485f-8159-f8d6ff8ed160.png)
   
![image](https://user-images.githubusercontent.com/8312839/204580362-cae1af84-6e99-4cd8-8cd7-c925f34f1771.png)
   
![image](https://user-images.githubusercontent.com/8312839/204580412-a17d9391-755f-46df-b598-0d5018407fd4.png)
   
![image](https://user-images.githubusercontent.com/8312839/204580553-4e03ec20-d23d-4b63-a36f-f725a5d69746.png)
   
![image](https://user-images.githubusercontent.com/8312839/204580620-39da2985-db13-4d82-930f-8999cf4724b3.png)
   
   
   
   ### Environment
   
   - browser type and version: Chrome 107.0.5304.110 (Official Build) (x86_64)
   - superset version: I just clone the repo and use non-dev docker-compose 
script.
   - python version: `3.10.6`
   - node.js version: `12.0`
   - 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. (No stack trace produced).
   - [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
   I uploaded a video to the Superset Slack channel with the steps to 
replicated it.
   
https://apache-superset.slack.com/files/U02U4GLFWJC/F04CWRUQ1RR/superset_-_29_november_2022.mp4
   
   


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