TIMESTAMP behaviour does not match sql standard
See original GitHub issueIt 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:
- Created 7 years ago
- Reactions:3
- Comments:10 (10 by maintainers)
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
As part of this project, we will need to identify any backward incompatible behavior and document it