You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "robertolucchetti (via GitHub)" <gi...@apache.org> on 2026/03/26 13:55:42 UTC
[I] Line Chart Time Grain Hour Superset generate a wrong chart, probably due to wrong SQL query [superset]
robertolucchetti opened a new issue, #38882:
URL: https://github.com/apache/superset/issues/38882
### Bug description
When using Line Chart with Time Grain Hour, Superset generates a wrong chart. The issue is present in v6.0.0 and v6.1.0rc1 also, while versione 4.1.2 works fine.
Here the wrong chart with Time Grain = Hour
<img width="1100" height="466" alt="Image" src="https://github.com/user-attachments/assets/e3992dc6-b04a-4e20-9ec0-72f9c5901fe9" />
While here a correct chart with Time Grain = Day
<img width="1103" height="474" alt="Image" src="https://github.com/user-attachments/assets/63277ab6-f18d-414b-b558-7d09c2db0643" />
Probably the reason is the SQL query generated without the DATE() truncation:
DATE_ADD(start_datetime, INTERVAL (HOUR(start_datetime)) HOUR) AS start_datetime, ā¦
GROUP BY DATE_ADD(start_datetime, INTERVAL (HOUR(start_datetime)) HOUR)
It should be something like this:
DATE_ADD(DATE(start_datetime), INTERVAL HOUR(start_datetime) HOUR) AS start_datetime, ā¦
GROUP BY DATE_ADD(DATE(start_datetime), INTERVAL HOUR(start_datetime) HOUR)
Is there a fix for that, or a plan for a patch?
### Screenshots/recordings
_No response_
### Superset version
6.0.0
### Python version
3.10
### Node version
Not applicable
### Browser
Chrome
### Additional context
_No response_
### Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [ ] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [ ] 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] Line Chart Time Grain Hour Superset generate a wrong chart, probably due to wrong SQL query [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed issue #38882: Line Chart Time Grain Hour Superset generate a wrong chart, probably due to wrong SQL query
URL: https://github.com/apache/superset/issues/38882
--
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] Line Chart Time Grain Hour Superset generate a wrong chart, probably due to wrong SQL query [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #38882:
URL: https://github.com/apache/superset/issues/38882#issuecomment-4135074604
<!-- Greeting -->
Hi @robertolucchetti! I'm [Dosu](https://go.dosu.dev/dosubot) and Iām helping the superset team.
<!-- Answer -->
This is a known regression in Superset 6.x! The issue is tracked in [#36798](https://github.com/apache/superset/issues/36798), and a fix is proposed in [PR #38617](https://github.com/apache/superset/pull/38617) (not yet merged).
**Root cause:** SQLGlot sanitization and SQLAlchemy's proxy mechanism strip the bare `DATE({col})` call during query construction, specifically affecting HOUR and sub-hour time grains. DAY/MONTH/YEAR grains are unaffected.
**Workaround:** Add this to your `superset_config.py`:
```python
def FLASK_APP_MUTATOR(app):
from superset.db_engine_specs.mysql import MySQLEngineSpec
orig = MySQLEngineSpec.get_time_grain_expressions
@classmethod
def patched(cls):
d = dict(orig() or {})
d["PT1H"] = "DATE_ADD(CAST(DATE({col}) AS DATETIME), INTERVAL HOUR({col}) HOUR)"
return d
try:
orig.cache_clear()
except Exception:
pass
MySQLEngineSpec.get_time_grain_expressions = patched
return app
```
The `CAST(DATE({col}) AS DATETIME)` wrapper prevents the renderer from stripping the truncation function.
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=brand-link).*
---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback/f0dee3e4-41cf-4500-95d8-a18fa16641e8?feedback_type=great_response&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/f0dee3e4-41cf-4500-95d8-a18fa16641e8?feedback_type=irrelevant_answer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/f0dee3e4-41cf-4500-95d8-a18fa16641e8?feedback_type=incorrect_sources&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/f0dee3e4-41cf-4500-95d8-a18fa16641e8?feedback_type=too_verbose&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/f0dee3e4-41cf
-4500-95d8-a18fa16641e8?feedback_type=hallucination&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-hallucination) | [Report š](https://app.dosu.dev/response-feedback/f0dee3e4-41cf-4500-95d8-a18fa16641e8?feedback_type=bug_report&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-bug_report) | [Other](https://app.dosu.dev/response-feedback/f0dee3e4-41cf-4500-95d8-a18fa16641e8?feedback_type=other&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-other)</sup>
[](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=chat-badge) [](https://cursor.com/link/prompt?text=This%20is%20a%20known%20regression%20in%20Superset%206.x%21%20The%20issue%20is%20tracked%20in%20%5B%2336798%5D%28https%3A//github.com/apache/superset/issues/36798%29%2C%20and%20a%20fix%20is%20proposed%20in%20%5BPR%20%2338617%5D%28https%3A//github.com/apache/superset/pull/38617%29%20%28not%20yet%20merged%29.%0A%0A%2A%2ARoot%20cause%3A%2A%2A%20SQLGlot%20sanitization%20and%20SQLAlchemy%27s%20proxy%20mechanism%20strip%20the%20bare%20%60DATE%28%7Bcol%7D%29%60%20call%20during%20query%20construction%2C%20specifically%20affecting%20HOUR%20and%20sub-hour%20time%20grains.%20DAY/MONTH/YEAR%20grains%20are%20unaffected.%0A%0A%2A%2AWorkaround%3A%2A%2A%20Add%20this%20to%20your%20%60supers
et_config.py%60%3A%0A%0A%60%60%60python%0Adef%20FLASK_APP_MUTATOR%28app%29%3A%0A%20%20%20%20from%20superset.db_engine_specs.mysql%20import%20MySQLEngineSpec%0A%0A%20%20%20%20orig%20%3D%20MySQLEngineSpec.get_time_grain_expressions%0A%0A%20%20%20%20%40classmethod%0A%20%20%20%20def%20patched%28cls%29%3A%0A%20%20%20%20%20%20%20%20d%20%3D%20dict%28orig%28%29%20or%20%7B%7D%29%0A%20%20%20%20%20%20%20%20d%5B%22PT1H%22%5D%20%3D%20%22DATE_ADD%28CAST%28DATE%28%7Bcol%7D%29%20AS%20DATETIME%29%2C%20INTERVAL%20HOUR%28%7Bcol%7D%29%20HOUR%29%22%0A%20%20%20%20%20%20%20%20return%20d%0A%0A%20%20%20%20try%3A%0A%20%20%20%20%20%20%20%20orig.cache_clear%28%29%0A%20%20%20%20except%20Exception%3A%0A%20%20%20%20%20%20%20%20pass%0A%0A%20%20%20%20MySQLEngineSpec.get_time_grain_expressions%20%3D%20patched%0A%20%20%20%20return%20app%0A%60%60%60%0A%0AThe%20%60CAST%28DATE%28%7Bcol%7D%29%20AS%20DATETIME%29%60%20wrapper%20prevents%20the%20renderer%20from%20stripping%20the%20truncation%20function.) [](https://go.dosu.dev/discord-bot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=join-discord) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/38882)
--
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] Line Chart Time Grain Hour Superset generate a wrong chart, probably due to wrong SQL query [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #38882:
URL: https://github.com/apache/superset/issues/38882#issuecomment-4156710534
Hopefully we can get it fixed for an upcoming release, but as always, there are lots of things competing for attention. If you want to review and/or test #38617 that might help us get it merged and then released. Meanwhile, I'll close this in favor of https://github.com/apache/superset/issues/36798
--
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] Line Chart Time Grain Hour Superset generate a wrong chart, probably due to wrong SQL query [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #38882:
URL: https://github.com/apache/superset/issues/38882#issuecomment-4141889097
<!-- Answer -->
I'm glad the workaround helps! As for the fix, [PR #38617](https://github.com/apache/superset/pull/38617) is still **open** and hasn't been merged yet. There's no assigned milestone or target release version at this time.
I'm not part of the Superset maintainer team, so I can't speak to their release plans. You might want to leave a comment on the PR or ping the maintainers to get visibility on when it might be included in a release.
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=brand-link).*
---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback/2d791efe-74da-45ca-9e74-23e0f51caf21?feedback_type=great_response&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/2d791efe-74da-45ca-9e74-23e0f51caf21?feedback_type=irrelevant_answer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/2d791efe-74da-45ca-9e74-23e0f51caf21?feedback_type=incorrect_sources&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/2d791efe-74da-45ca-9e74-23e0f51caf21?feedback_type=too_verbose&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/2d791efe-74da
-45ca-9e74-23e0f51caf21?feedback_type=hallucination&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-hallucination) | [Report š](https://app.dosu.dev/response-feedback/2d791efe-74da-45ca-9e74-23e0f51caf21?feedback_type=bug_report&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-bug_report) | [Other](https://app.dosu.dev/response-feedback/2d791efe-74da-45ca-9e74-23e0f51caf21?feedback_type=other&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-other)</sup>
[](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=chat-badge) [](https://cursor.com/link/prompt?text=I%27m%20glad%20the%20workaround%20helps%21%20As%20for%20the%20fix%2C%20%5BPR%20%2338617%5D%28https%3A//github.com/apache/superset/pull/38617%29%20is%20still%20%2A%2Aopen%2A%2A%20and%20hasn%27t%20been%20merged%20yet.%20There%27s%20no%20assigned%20milestone%20or%20target%20release%20version%20at%20this%20time.%0A%0AI%27m%20not%20part%20of%20the%20Superset%20maintainer%20team%2C%20so%20I%20can%27t%20speak%20to%20their%20release%20plans.%20You%20might%20want%20to%20leave%20a%20comment%20on%20the%20PR%20or%20ping%20the%20maintainers%20to%20get%20visibility%20on%20when%20it%20might%20be%20included%20in%20a%20release.) [](https://go.dosu.dev/discord-bot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=join-discord) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/38882)
--
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] Line Chart Time Grain Hour Superset generate a wrong chart, probably due to wrong SQL query [superset]
Posted by "robertolucchetti (via GitHub)" <gi...@apache.org>.
robertolucchetti commented on issue #38882:
URL: https://github.com/apache/superset/issues/38882#issuecomment-4141882298
OK @dosu the workaround looks fine.
Do you guys plan to include the fix in the next release?
--
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