You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "jose-l-goncalves-alb (via GitHub)" <gi...@apache.org> on 2024/12/13 19:46:33 UTC
[I] time_grain variable (sql templating) is always None [superset]
jose-l-goncalves-alb opened a new issue, #31446:
URL: https://github.com/apache/superset/issues/31446
### Bug description
At superset 3.1.3 time_grain variable (sql templating) has correct value, ex.: PT1M or P1D, accordingly the value chosen from a Time Grain filter.
At superset 4.1.1 time_grain variable (sql templating) has always **None** value, no matter the value chosen from a time grain filter that I have at dashboard.
Something changed from 3.1.3 to 4.1.1 version and is not working.
We use this variable, time_grain, to decide which table we use at data set (we have *_hour/day/month tables with distinct aggregation time). **This feature is very important to us.**
### Screenshots/recordings
_No response_
### Superset version
4.1.1
### Python version
3.10
### Node version
Not applicable
### Browser
Chrome
### Additional context
FEATURE_FLAGS = {
"ALERT_REPORTS": True,
"ENABLE_TEMPLATE_PROCESSING": True,
"ENABLE_ADVANCED_DATA_TYPES": True,
"ALLOW_FULL_CSV_EXPORT": True,
"HORIZONTAL_FILTER_BAR": True,
"DRILL_TO_DETAIL": False,
"DRILL_BY": False
}
### Checklist
- [X] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [X] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [X] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
--
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
Re: [I] time_grain variable (sql templating) is always None [superset]
Posted by "Vitor-Avila (via GitHub)" <gi...@apache.org>.
Vitor-Avila commented on issue #31446:
URL: https://github.com/apache/superset/issues/31446#issuecomment-2755678352
I have a potential fix here: https://github.com/apache/superset/pull/32871
--
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
Re: [I] time_grain variable (sql templating) is always None [superset]
Posted by "davidriverapericas (via GitHub)" <gi...@apache.org>.
davidriverapericas commented on issue #31446:
URL: https://github.com/apache/superset/issues/31446#issuecomment-2674628014
Hi all
Is it going to be fixed soon?
In my case, we are using the "time_grain" in our Datasets with jinja with
`/*
Time grain: {{ time_grain }}
*/`
but it always returns None
`
/*
Time grain: None
*/
`
We are using this for example in a Table chart. When we set the Time Grain to "Month" for example, the Dataset (expecting the "time_grain" to be "P1M" would group the rows by months, but as a default we group the rows by days. So, as time_grain is None, it returns rows per day.
But on the other side, the table chart is rendering the date column taking into account the granularity:

resulting the chart displaying wrong information.
I hope this is fixed very soon
Cheers
David
--
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
Re: [I] time_grain variable (sql templating) is always None [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #31446:
URL: https://github.com/apache/superset/issues/31446#issuecomment-2542175874
<!-- Answer -->
The issue with the `time_grain` variable always being `None` in Superset version 4.1.1 is due to a change documented in the changelog. Specifically, there was a change affecting how time grains are handled when using Jinja templating in datasets. This change likely introduced the behavior where `time_grain` is set to `None` <sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/CHANGELOG.md)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
---
<sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/d479afc7-d970-4861-8e2c-220eafc89dfa?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/d479afc7-d970-4861-8e2c-220eafc89dfa?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/d479afc7-d970-4861-8e2c-220eafc89dfa?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/d479afc7-d970-4861-8e2c-220eafc89dfa?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/d479afc7-d970-4861-8e2c-220eafc89dfa?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/d479afc7-d970-4861-8e2c-220eafc89dfa?feedback_type=other)</sup>
--
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
Re: [I] time_grain variable (sql templating) is always None [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #31446:
URL: https://github.com/apache/superset/issues/31446#issuecomment-2675355558
I'm not sure the root cause of this, but I've added a few assignees who might be able to help and/or find others who are encountering this. It's probably not the highest priority for core maintainers at the moment, so if anyone on the thread is willing to dig in and investigate a fix, we'd surely appreciate the help!
--
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
Re: [I] time_grain variable (sql templating) is always None [superset]
Posted by "tylercb (via GitHub)" <gi...@apache.org>.
tylercb commented on issue #31446:
URL: https://github.com/apache/superset/issues/31446#issuecomment-2566601710
I've also experienced this issue after a recent Preset change. In my case, I have an aggregate table with a Custom SQL dimension using the `time_grain` passed in from a dashboard Time grain filter. Previously, this worked perfectly, but recently the value is always `None`.
```sql
date_trunc(
case '{{ time_grain }}'
when 'P1Y' then 'year'
when 'P3M' then 'quarter'
when 'P1M' then 'month'
when 'P1W' then 'week'
when 'P1D' then 'day'
end,
cohort_start_date_pacific
)
```

--
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
Re: [I] time_grain variable (sql templating) is always None [superset]
Posted by "Dronesh77 (via GitHub)" <gi...@apache.org>.
Dronesh77 commented on issue #31446:
URL: https://github.com/apache/superset/issues/31446#issuecomment-2543589683
Hey @jose-l-goncalves-alb !
I'd be happy to assist you in this issue with regard to the time_grain variable not being populated correctly on Superset 4.1.1. To know better and give a resolution, could you please give a screenshot or video of what exactly you see happening?
This will show me the exact behavior of the problem and ensure the resolution addresses the problem you are running into.
--
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
Re: [I] time_grain variable (sql templating) is always None [superset]
Posted by "jose-l-goncalves-alb (via GitHub)" <gi...@apache.org>.
jose-l-goncalves-alb commented on issue #31446:
URL: https://github.com/apache/superset/issues/31446#issuecomment-2545426185
I forgot to mention that we are using postgresql to store the superset metadata (@3.1.3 & 4.1.1 versions) and our datasets connect to a postgresql database.
As you can see below, with superset 3.1.3 version I have a dataset that show the time_grain sql template variable, and at the dashboard the corresponding chart show the correct code (P3M) accordingly the value select (Quarter) at time grain filter.
**3.1.3 DataSet:**

**3.1.3 Chart showing a default time_grain code:**

**3.1.3 Dashboard showing a correct time_grain code, for all values of time grain filter:**

As you can see below, with superset 4.1.1 version I have a dataset that show the time_grain sql template variable, and at the dashboard the corresponding chart **don't** show the correct code (P3M) accordingly the value select (Quarter) at time grain filter.
**4.1.1 DataSet:**

**4.1.1 Chart showing None time_grain:**

**4.1.1 Dashboard don't show the time_grain code, even if we select other value from time grain filter:**

I hope that this info help you @Dronesh77 to clarify this issue.
--
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
Re: [I] time_grain variable (sql templating) is always None [superset]
Posted by "jose-l-goncalves-alb (via GitHub)" <gi...@apache.org>.
jose-l-goncalves-alb commented on issue #31446:
URL: https://github.com/apache/superset/issues/31446#issuecomment-2618455966
There are any plans to solve this issue ?
--
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
Re: [I] time_grain variable (sql templating) is always None [superset]
Posted by "Vitor-Avila (via GitHub)" <gi...@apache.org>.
Vitor-Avila closed issue #31446: time_grain variable (sql templating) is always None
URL: https://github.com/apache/superset/issues/31446
--
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