jordiisidro opened a new issue, #22774:
URL: https://github.com/apache/superset/issues/22774
A clear and concise description of what the bug is.
#### How to reproduce the bug
The variable time_grain used in SQL templating is always None
Other variables like from_dttm work fine.
Sample query:
select date_trunc(
{%- if time_grain == 'P1D' -%}
'day'
{%- elif time_grain == 'P1W' -%}
'week'
{%- elif time_grain == 'P1M' -%}
'month'
{%- elif time_grain == 'P3M' -%}
'quarter'
{%- elif time_grain == 'P1Y' -%}
'year'
{%- elif time_grain == 'P1Y' -%}
'year'
{% else %}
'month'
{%- endif -%}
, data) as data
, tecnologia, proveidor, count(distinct id_ticket) as incidencies
from inc_pet i
where {% if from_dttm is not none %}
i.data >= '{{ from_dttm }}' AND
{% endif %}
{% if to_dttm is not none %}
i.data < '{{ to_dttm }}' AND
{% endif %}
1=1
group by date_trunc(
{%- if time_grain == 'P1D' -%}
'day'
{%- elif time_grain == 'P1W' -%}
'week'
{%- elif time_grain == 'P1M' -%}
'month'
{%- elif time_grain == 'P3M' -%}
'quarter'
{%- elif time_grain == 'P1Y' -%}
'year'
{%- elif time_grain == 'P1Y' -%}
'year'
{% else %}
'month'
{%- endif -%}
, data)
, tecnologia, proveidor
### Expected results
I expect that when Granularity chances the time_grain value changes
### Actual results
time_grain always return None
### Environment
- superset version: 2.0.1
### 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.
--
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]