superset
superset copied to clipboard
Templates are not being rendered in dataset metrics
Templates used in dataset metrics are not being rendered 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.
- Go to Datasets
- Open
flights
dataset - 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)
- Save the dataset
- Go to create a new Chart (for example, Time Series bar chart, v2)
- Select
flights
dataset - Drop
My Metric
into the Metric section of the chart - Update the chart.
- Create a new adhoc metric with the same SQL code than the dataset metric.
- 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
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
Assigning to @villebro for the moment, in hopes that he either has some insight here, or can redirect the issue to another contributor who might be able to assist further.
Repro'd, I'll open a fix asap
@cbuffevant @rusackas please check out #22280 .