You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "mapledan (via GitHub)" <gi...@apache.org> on 2023/09/14 14:23:18 UTC
[GitHub] [superset] mapledan opened a new issue, #25301: `GENERIC_CHART_AXES` affects the Jinja template
mapledan opened a new issue, #25301:
URL: https://github.com/apache/superset/issues/25301
The `GENERIC_CHART_AXES=TRUE` will impact the control panel in the frontend, so the `time_range `will not be included in the request body as a result.
I'm uncertain whether this logic adjustment should be handled by the frontend or the backend.
But I'm certain that the `time_range `not in request body will affect the API(`/api/v1/chart/data`) parsing of `to_dttm` and `from_dttm`.
#### How to reproduce the bug
1. The Dataset use virtual table with jinja template.
```
SELECT *
FROM main.channels
where true
{% if from_dttm is not none %}
and created >= '{{from_dttm}}'
{% endif %}
{% if to_dttm is not none %}
and created < '{{to_dttm}}'
{% endif %}
```
2. Go to Explore and create a Chart.
3. The Jinja template where from_dttm becomes `None`, and to_dttm becomes `today`. Even my temporal filter is set to `2020-01-01 <= x < 2021-01-01`.
### Expected results
`SELECT
*
FROM main.channels
where true
and created >= '2020-01-01T00:00:00'
and created < '2021-01-01T00:00:00'`
### Actual results
`SELECT
*
FROM main.channels
where true
and created < '2023-09-14T00:00:00'`
#### Screenshots

### Environment
(please complete the following information):
- browser type and version:
- superset version: `superset version`
- python version: `python --version`
- node.js version: `node -v`
- any feature flags active:
### 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
In the Explore, the fetch chart is using the /api/v1/chart/data.
The request body are different between feature flag TRUE or FALSE.
When GENERIC_CHART_AXES=TRUE:
```
"queries": [
{
"filters": [
{
"col": "created",
"op": "TEMPORAL_RANGE",
"val": "2020-01-01 : 2021-01-01"
}
],
"extras": {
"time_grain_sqla": "P1D",
"having": "",
"where": ""
},
"applied_time_extras": {},
"columns": [
"created",
"channel_id",
"creator"
],
"orderby": [],
"annotation_layers": [],
"row_limit": 1000,
"series_limit": 0,
"order_desc": true,
"url_params": {
"datasource_id": "11",
"datasource_type": "table"
},
"custom_params": {},
"custom_form_data": {},
"post_processing": []
}
]
```
When GENERIC_CHART_AXES=FALSE:
```
"queries": [
{
"time_range": "2020-01-01 : 2021-01-01",
"granularity": "created",
"filters": [],
"extras": {
"time_grain_sqla": "P1D",
"having": "",
"where": ""
},
"applied_time_extras": {},
"columns": [
"created",
"channel_id",
"creator"
],
"orderby": [],
"annotation_layers": [],
"row_limit": 1000,
"series_limit": 0,
"order_desc": true,
"url_params": {
"datasource_id": "11",
"datasource_type": "table"
},
"custom_params": {},
"custom_form_data": {},
"post_processing": []
}
]
```
--
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] Vitor-Avila commented on issue #25301: `GENERIC_CHART_AXES` affects the Jinja template
Posted by "Vitor-Avila (via GitHub)" <gi...@apache.org>.
Vitor-Avila commented on issue #25301:
URL: https://github.com/apache/superset/issues/25301#issuecomment-1728719802
I was looking at the code, and I suspect that the Today date for the `{{ to_dttm }} ` macro comes from [here](https://github.com/apache/superset/blob/master/superset/utils/date_parser.py#L254-L259):
``` python
_since = parse_human_datetime(since) if since else None
_until = (
parse_human_datetime(until)
if until
else parse_human_datetime(_relative_end)
)
```
Note that `_since` is set to `None` if undefined, however `_until` would be set to `parse_human_datetime(_relative_end)` and `_relative_end` is set to `"today"` [here](https://github.com/apache/superset/blob/master/superset/utils/date_parser.py#L179).
I changed this to `_until = parse_human_datetime(until) if until else None` and confirmed the issue is fixed, but I suspect that it defaults to `"today"` for a reason. @zhaoyongjie would you happen to know if we need to keep the `"today"` as the default value here? Sorry for the direct tag, but I noticed you actually created this file so you might have more context.
--
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] `GENERIC_CHART_AXES` affects the Jinja template [superset]
Posted by "yousoph (via GitHub)" <gi...@apache.org>.
yousoph closed issue #25301: `GENERIC_CHART_AXES` affects the Jinja template
URL: https://github.com/apache/superset/issues/25301
--
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