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

Timestamp with time zone not mapped correctly #366

Closed
1 task done
john-bodley opened this issue Apr 28, 2023 · 1 comment
Closed
1 task done

Timestamp with time zone not mapped correctly #366

john-bodley opened this issue Apr 28, 2023 · 1 comment

Comments

@john-bodley
Copy link
Contributor

john-bodley commented Apr 28, 2023

Expected behavior

Per the Trino documentation the Trino DB-API should correctly map timestamps with time zone to Python datetime objects.

Actual behavior

Per the example provided in the Trino documentation,

from trino.dbapi import connect

cursor = connect(host="localhost").cursor()
cursor.execute("SELECT timestamp '2012-10-31 01:00 UTC' AT TIME ZONE 'America/Los_Angeles'")
rows = cursor.fetchall()
print(rows)

returns

[[datetime.datetime(2012, 10, 30, 18, 0, tzinfo=<DstTzInfo 'America/Los_Angeles' LMT-1 day, 16:07:00 STD>)]]

which is incorrect by 53 minutes due to how pytz time zones are bound. The expected outcome is

[[datetime.datetime(2012, 10, 30, 18, 0, tzinfo=<DstTzInfo 'America/Los_Angeles' PDT-1 day, 17:00:00 DST>)]]

Steps To Reproduce

See above.

Log output

This article outlines the fundamental issue which states,

pytz uses its own non-standard interface for handling time zone information that is partially but not entirely compatible with the way Python's datetime library was intended to work …

See this StackOverflow post for additional information and how time zone localization works with the pytz package.

Operating System

Ubuntu

Trino Python client version

0.321.0

Trino Server version

393.0

Python version

3.9.16

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
@hashhar
Copy link
Member

hashhar commented May 15, 2023

Fixed via #368

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants