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

Add to_local_time function for converting timestamps with timezones to timestmaps without timezones #11358

Closed
alamb opened this issue Jul 9, 2024 · 0 comments · Fixed by #11347
Labels
enhancement New feature or request

Comments

@alamb
Copy link
Contributor

alamb commented Jul 9, 2024

Is your feature request related to a problem or challenge?

The actual need is implementing date_bin that correctly bins dates on timezone correct timestamps (e.g. not UTC) as described by @Abdullahsab3 in #10368

This ticket tracks adding the to_local_time function portion of @Abdullahsab3 's suggestion in DataFusion while we work on getting consensus if we want to change the semantics of the arrow cast kernel: apache/arrow-rs#5826

Describe the solution you'd like

Add function to_local_time that takes a timestamp/column as an argument, and a timezone as another argument. For example

> select to_local_time('2020-11-30T08:00:00.000Z'::timestamp, 'Europe/Brussels');
-- translates to '2020-11-30T08:00:00.000Z'::timestamp + interval '1 hour'
< '2020-11-30T09:00:00'

The difference between this and the at time zone operator is:
The at time zone operator seems to be only adding timezone/offset information to the timestamp if I understood correctly. the proposed to_local_time function should ideally apply that offset to the provided timestamp. The same example above would be:

> select '2020-11-30T08:00:00.000Z'::timestamp at time zone 'Europe/Brussels';
+----------------------------------+
| Utf8("2020-11-30T08:00:00.000Z") |
+----------------------------------+
| 2020-11-30T08:00:00+01:00        |
+----------------------------------+
1 row in set. Query took 0.002 seconds.

Describe alternatives you've considered

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant