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

Time Range filter gets Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True #8943

Open
philippe-lavoie opened this issue Jan 9, 2020 · 1 comment
Labels

Comments

@philippe-lavoie
Copy link

@philippe-lavoie philippe-lavoie commented Jan 9, 2020

A clear and concise description of what the bug is.

In PostgreSQL, my products are associated with an industry. I wanted an area chart to see how each industry is trending over time, but I get an error WHEN the time range is greater than a month

Expected results

I should be able to crate an area chart without filtering.

Actual results

Get an error

2020-01-09 11:03:17,062:INFO:root:SELECT industry AS industry, DATE_TRUNC('week', creation_time) AS __timestamp, COUNT(*) AS count
FROM insight.product GROUP BY industry, DATE_TRUNC('week', creation_time) ORDER BY count DESC
LIMIT 10000
2020-01-09 11:03:17,068:INFO:root:Database.get_sqla_engine(). Masked URL: postgresql://postgres:XXXXXXXXXX@XXXXXXX/YYYYYYY
2020-01-09 11:03:17,110:ERROR:root:Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True
Traceback (most recent call last):
File "/mnt/e/conda3/envs/superset/lib/python3.6/site-packages/pandas/core/arrays/datetimes.py", line 1861, in objects_to_datetime64ns
values, tz_parsed = conversion.datetime_to_datetime64(data)
File "pandas/_libs/tslibs/conversion.pyx", line 185, in pandas._libs.tslibs.conversion.datetime_to_datetime64
ValueError: Array must be all same time zone

How to reproduce the bug

Create a table in postgresql

CREATE TABLE public.test_tz (
creation_time timestamptz NOT NULL,
industry varchar NOT NULL
);

Populate the table somehow, at one point the error gets triggered. In my case it's filtering by week above a month.

Environment

Ubuntu under Windows (WSL)

  • superset version: Superset 0.35.1
  • python version: 3.6
  • node.js version: not installed
  • npm version: not installed

Checklist

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 there are 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.

I have found a similar issue stating that's it's fixed. It's partially fixed (I guess)

Additional context

It's very weird that filtering fixes it. I guess some of the entries are on a date. What's ever more weird is that when you state timestamptz in Postgresql it automatically normalzed all entries as UTC (which is odd since I wanted to keep the timezone information, but expected). So Panda insisting on specifying an utc parameter is very odd indeed.

@issue-label-bot issue-label-bot bot added the #bug label Jan 9, 2020
@issue-label-bot

This comment has been minimized.

Copy link

@issue-label-bot issue-label-bot bot commented Jan 9, 2020

Issue-Label Bot is automatically applying the label #bug to this issue, with a confidence of 0.88. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.