Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True [Continued]
Make sure these boxes are checked before submitting your issue - thank you!
- [x] I have checked the superset logs for python stacktraces and included it here as text if 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
Superset version
0.25.2 Postgres V10
Actual results
When setting TimeGrain to e.g. month, the following error occurs:

Note in the picture that I manually changed the value of utc=False to utc=True in viz.py. This did not solved the problem.
The SQL request in itself works well with the PostgresDB ;

The problem observed here is similar to the one discussed in issue #4250. The PR merged in issue 4250 did not solved the problem for me.
Steps to reproduce
- In a PostgresDB V10 create a table with a column typed 'timestamp without time zone'.
- Try to create a Line Chart using this table and set a TimeGrain value.
After further investigation, the problem is solved by modifying viz.py to set:
df[DTTM_ALIAS] = pd.to_datetime(df[DTTM_ALIAS], utc=True, format=timestamp_format)
instead of utc=False.
Should this not be set by default as all SQL queries are made using AT TIME ZONE 'UTC' ?
It happens to me as well.
@sbarlock your solution worked for me as well 👍 thank you!
@mistercrunch Is it worth for me to submit a PR or is this fix just valid for PostgresDB users?
Cheers,
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.
Seems like this is still a real issue, at least for me?
Hi @villebro, I'm tagging you here as you've been involved in timestamps things earlier?
Any comments on
df[DTTM_ALIAS] = pd.to_datetime(df[DTTM_ALIAS], utc=True, format=timestamp_format) what @sbarlock proposed earlier?
This seems to be a problem for several users (including me).
@kakoni can you open a new ticket for this? I'm happy to work on this issue, but want to make sure I fully understand all the details and can replicate this on master and/or 0.34.1.
This is surely still an issue
still not solved. any solution without changing code?
@Towhid1 as stated above, please open a new ticket with all the necessary details and I will be happy to help.
FYI, the issue is still present in 0.37.0.
I understand a new ticket would be required to open a proper PR. In the meantime, a quick and dirty workaround — not always feasible, I admit — is to change the db column type from DATE to TIMESTAMP.