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

Incorrect results for last_day_of_month function #2851

Closed
oneonestar opened this issue Feb 17, 2020 · 0 comments
Closed

Incorrect results for last_day_of_month function #2851

oneonestar opened this issue Feb 17, 2020 · 0 comments
Assignees
Labels
bug Something isn't working correctness
Milestone

Comments

@oneonestar
Copy link
Member

The result is incorrect when a timestamp with time zone <= UTC 00:00 is provided.

presto> select
     ->     last_day_of_month(timestamp '2020-02-17 00:00:00.000 +02:00'),
     ->     last_day_of_month(timestamp '2020-02-17 00:00:00.000 +01:00'),
     ->     last_day_of_month(timestamp '2020-02-17 00:00:00.000 +00:00'),
     ->     last_day_of_month(timestamp '2020-02-17 00:00:00.000 -01:00'),
     ->     last_day_of_month(timestamp '2020-02-17 00:00:00.000 -02:00');
   _col0    |   _col1    |   _col2    |   _col3    |   _col4
------------+------------+------------+------------+------------
 2020-02-29 | 2020-02-29 | 2020-03-01 | 2020-03-01 | 2020-03-01

This also affect last_day_of_month(current_timestamp), depends on the timezone of the client.

⇒  java  -Duser.timezone=Asia/Tokyo  -jar ./presto-cli-*-executable.jar
presto> select
     ->     current_timestamp,
     ->     last_day_of_month(current_timestamp),
     ->     last_day_of_month(timestamp '2020-02-17 00:00:00.000 Asia/Tokyo'),
     ->     last_day_of_month(timestamp '2020-02-17 00:00:00.000 Asia/Hong_Kong'),
     ->     last_day_of_month(timestamp '2020-02-17 00:00:00.000 Australia/North'),
     ->     last_day_of_month(timestamp '2020-02-17 00:00:00.000 America/New_York'),
     ->     last_day_of_month(timestamp '2020-02-17 00:00:00.000 America/Los_Angeles'),
     ->     last_day_of_month(timestamp '2020-02-17 00:00:00.000 Canada/Atlantic');
               _col0                |   _col1    |   _col2    |   _col3    |   _col4    |   _col5    |   _col6    |   _col7
------------------------------------+------------+------------+------------+------------+------------+------------+------------
 2020-02-17 15:54:29.193 Asia/Tokyo | 2020-02-29 | 2020-02-29 | 2020-02-29 | 2020-02-29 | 2020-03-01 | 2020-03-01 | 2020-03-01

⇒  java  -Duser.timezone=America/Los_Angeles  -jar ./presto-cli-*-executable.jar
presto> select
     ->     current_timestamp,
     ->     last_day_of_month(current_timestamp),
     ->     last_day_of_month(timestamp '2020-02-17 00:00:00.000 Asia/Tokyo'),
     ->     last_day_of_month(timestamp '2020-02-17 00:00:00.000 Asia/Hong_Kong'),
     ->     last_day_of_month(timestamp '2020-02-17 00:00:00.000 Australia/North'),
     ->     last_day_of_month(timestamp '2020-02-17 00:00:00.000 America/New_York'),
     ->     last_day_of_month(timestamp '2020-02-17 00:00:00.000 America/Los_Angeles'),
     ->     last_day_of_month(timestamp '2020-02-17 00:00:00.000 Canada/Atlantic');
                    _col0                    |   _col1    |   _col2    |   _col3    |   _col4    |   _col5    |   _col6    |   _col7
---------------------------------------------+------------+------------+------------+------------+------------+------------+------------
 2020-02-16 22:54:56.653 America/Los_Angeles | 2020-03-01 | 2020-02-29 | 2020-02-29 | 2020-02-29 | 2020-03-01 | 2020-03-01 | 2020-03-01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctness
Development

Successfully merging a pull request may close this issue.

2 participants