Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True [Continued] #5015

Closed
3 tasks done
guinny65 opened this issue May 16, 2018 · 11 comments
Closed
3 tasks done
Labels
inactive Inactive for >= 30 days

Comments

@guinny65
Copy link

Make sure these boxes are checked before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if any
  • I have reproduced the issue with at least the latest released version of superset
  • 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:
image

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 ;
image

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.
@guinny65
Copy link
Author

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' ?

@jorgebg
Copy link

jorgebg commented Jul 28, 2018

It happens to me as well.

@sbarlock your solution worked for me as well 👍 thank you!

@guinny65
Copy link
Author

@mistercrunch Is it worth for me to submit a PR or is this fix just valid for PostgresDB users?

Cheers,

@stale
Copy link

stale bot commented Apr 10, 2019

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.

@stale stale bot added the inactive Inactive for >= 30 days label Apr 10, 2019
@stale stale bot closed this as completed Apr 17, 2019
@Poincare
Copy link

Poincare commented May 3, 2019

Seems like this is still a real issue, at least for me?

@kakoni
Copy link
Contributor

kakoni commented Nov 1, 2019

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).

@villebro
Copy link
Member

villebro commented Nov 1, 2019

@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.

@gamebusterz
Copy link

This is surely still an issue

@Towhid1
Copy link

Towhid1 commented Nov 28, 2019

still not solved. any solution without changing code?

@villebro
Copy link
Member

@Towhid1 as stated above, please open a new ticket with all the necessary details and I will be happy to help.

@EBoisseauSierra
Copy link
Contributor

EBoisseauSierra commented Sep 10, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive Inactive for >= 30 days
Projects
None yet
Development

No branches or pull requests

8 participants