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

Timezone information is not passed from datetime objects through to ibis.literal #1459

Closed
cpcloud opened this Issue May 30, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@cpcloud
Member

cpcloud commented May 30, 2018

No description provided.

@cpcloud cpcloud added this to the 0.14 milestone May 30, 2018

@cpcloud cpcloud self-assigned this May 30, 2018

@cpcloud cpcloud changed the title from Timezone information is not passed from datetime objects in ibis.literal to Timezone information is not passed from datetime objects through to ibis.literal May 30, 2018

@missing-semicolon

This comment has been minimized.

Contributor

missing-semicolon commented Jun 5, 2018

Example

This works:

now_raw = dt.utcnow()
assert now_raw.tzinfo is None
assert ibis.literal(now_raw).type().timezone is None

This has an error in the final assertion:

now_utc = pytz.utc.localize(now_raw)
assert now_utc.tzinfo is not None
assert ibis.literal(now_utc).type().timezone is not None
@missing-semicolon

This comment has been minimized.

Contributor

missing-semicolon commented Jun 6, 2018

Another literal issue:

>>> client = ibis.bigquery.connect(etc)
>>> tab = client.table('example')
>>> tab.add_column(datetime.datetime.now(), 'test').compile()
"SELECT *, '2018-06-06 15:42:05' as `test`

Timestamp literals are not compiled as timestamps / datetimes in BQ.

@cpcloud

This comment has been minimized.

Member

cpcloud commented Jun 6, 2018

Yep, I'm working on a patch for that issue.

@cpcloud cpcloud closed this in d12baa0 Jun 7, 2018

missing-semicolon added a commit to missing-semicolon/ibis that referenced this issue Jun 11, 2018

Enable ibis.literal to detect and preserve when datetime has a timezone.
Closes ibis-project#1459

Author: Scott Lustig <scott.lustig@twosigma.com>

Closes ibis-project#1473 from missing-semicolon/timestamp-tz-literal and squashes the following commits:

0d5339b [Scott Lustig] Update test for literal timezone attr as string
1c8cf5c [Scott Lustig] Cast tzinfo to string
f2d7e1a [Scott Lustig] Merge branch 'master' of https://github.com/ibis-project/ibis into timestamp-tz-literal
02d2f94 [Scott Lustig] Implement and Test ibis.literal maintains timestamp's timezone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment