-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Date_add throws or produces wrong results when the result would …
…be nonexistent time in the time zone (#11845) Summary: Pull Request resolved: #11845 Date_add is computed on top of Unix timestamps (millis since epoch). When the unit being added is at least a day, this calculation is done in the "local" time zone (the session time zone in the case of Timestamps and the time zone associated with the value in the case of TImestampWithTimeZones). This local time is then converted back to a system time. When this calculation is done in a "local" time zone, the resulting local millis since epoch may not exist, e.g. in U.S. time zones that respect daylight savings time, it may fall in the hour 2:00-3:00 am on the day when the clocks move forward. In this case, date_add will throw an exception when this is done with Timestamps, and return the next valid time (e.g. 3 am in the example above) when this is done with TimestampWithTimeZones. To fix this I added a function correct_nonexistent_time to TimeZoneMap which can take a local timestamp and adjust it by the difference between the to time zones (e.g. moves it forward an hour in the case of the example above) and returns a timestamp that exists. This gets us behavior that is consistent with Presto Java. Reviewed By: HeidiHan0000 Differential Revision: D67154813 fbshipit-source-id: eb56ee93ade8da29eeec2ecec3004f5fd7ac12fd
- Loading branch information
1 parent
67a0c04
commit 42bd38a
Showing
5 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters