apache / apache/superset

master branch: datetime field shows incorrect time in Bar Charts and Scatter Plot with inconsistent deviations (vs correct time in SQL Lab)

Open
#37,925 10 comments 0 reactions 0 assignees View on GitHub
viz:charts:bar viz:charts:scatterplot
Dominant language
Python
Stars
74.8k
Forks
18.3k
Avg merge
2d 7h
Merged PRs (30d)
692

Description

### Bug description

In the latest master branch of Apache Superset, datetime-type fields exhibit inconsistent and incorrect behavior when used in visualizations, compared to raw SQL queries in SQL Lab:

SQL Lab: When executing a raw SELECT query on a table containing datetime data, the time values are returned correctly as stored in the database.
Datasets & Charts: When the same data is used to create a dataset and visualizations (eg:Bar Charts, Scatter Plots):
The datetime values displayed on the chart are incorrect.
The time deviation is inconsistent across different data points. Some timestamps are shifted by hours, while others are shifted by days, with no uniform offset.

Concrete example from the provided screenshots:

Image

Image

Image

This discrepancy breaks the reliability of time-based visualizations and makes it impossible to trust the results.

Expected Behavior
Datetime fields should display consistent, correct time values in both SQL Lab and all visualizations, regardless of the time grain or grouping used.
The time shown in the chart should exactly match the time returned by the raw SQL query.

Actual Behavior
SQL Lab: Time values are correct and match the source data.
Charts:
Time values are incorrect and do not reflect the source data.
Deviations are inconsistent across different data points, with shifts of varying hours and even days.

### Screenshots/recordings

_No response_

### Superset version

master / latest-dev

### Python version

3.9

### Node version

16

### Browser

Chrome

### Additional context

_No response_

### Checklist

- [ ] 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.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the discrepancy with the same datetime data in SQL Lab, a Bar Chart, and a Scatter Plot, comparing raw values with grouped or time-grained results. Trace datetime handling through the SQL Lab and visualization paths; done means chart timestamps consistently match the source query across time grains.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.