question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TIMESTAMP behaviour does not match sql standard

See original GitHub issue

It seems like meaning of TIMESTAMP and TIMESTAMP WITH TIMEZONE datatypes in Presto is totally not what is specified by SQL standard (and what other databases do).

This is my understanding of SQL 2003 standard (4.6.2 Datetimes):

TIMESTAMP WITH TIMEZONE represents absolute point in time. Typically databases store it internally as seconds since epoch in some fixed timezone (usually UTC). When querying TIMESTAMP WITH TIMEZONE data the values are presented to user in session timezone (yet session timezone is used just for presentation purposes).

TIMESTAMP does not represent specific point in time, but rather a reading of a wall clock+calendar. Selecting values from TIMESTAMP column should return same result set no matter what is the client’s session timezone.

While Presto semantics is different:

TIMESTAMP seems to do what TIMESTAMP WITH TIMEZONE should.

TIMESTAMP WITH TIMEZONE encodes explicit timezone information to each value stored in table. The sql standard does not define a type like that. But it does not seem very practical. Assuming that values selected from TIMESTAMP WITH TIMEZONE are presented to user in session timezone anyway, the per-row timezone information can be stripped away and all values can be stored in some arbitrary fixed timezone (e.g. UTC).

Please comment on the semantics. It seems wrong. Why the choice - as it is hard to believe that it was not done intentionally.

cc: @dain, @martint, @fiedukow, @cawallin

Edit: roadmap: https://github.com/prestodb/presto/issues/10326

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
fiedukowcommented, Mar 1, 2017

Please take a look at #7480 with fix implementation. Also here is doc detailing changes and backward compatibility issues as requested: https://docs.google.com/document/d/1UUDktZDx8fGwHZV4VyaEDQURorFbbg6ioeZ5KMHwoCk/edit?usp=sharing

1reaction
daincommented, Jan 24, 2017

As part of this project, we will need to identify any backward incompatible behavior and document it

Read more comments on GitHub >

github_iconTop Results From Across the Web

TIMESTAMP behaviour does not match sql standard · Issue #37
TIMESTAMP WITH TIMEZONE encodes explicit timezone information to each value stored in table. The sql standard does not define a type like that....
Read more >
Query Failed With Error "Timestamp '2020-09-28' is not ...
This article explains why query fails with error "Timestamp '2020-09-01' is not recognized" and how to avoid it.
Read more >
Database timestamps not matching - java - Stack Overflow
When debugging I've noticed that the Timestamp currentTime passed to it is usually about 1-2ms off the value in the database. I have...
Read more >
Functions, operators, and conditionals | BigQuery
Google Standard SQL for BigQuery supports operators. Operators are ... [NOT] LIKE, STRING and byte, Value does [not] match the pattern specified, Binary....
Read more >
What is a valid use case for using TIMESTAMP WITHOUT ...
TIMESTAMP WITHOUT TIME ZONE values are not a point on the timeline, not ... The SQL standard barely touches on issues of date-time...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found