alamb commented on issue #10602: URL: https://github.com/apache/datafusion/issues/10602#issuecomment-2122975595
@mhilton and I agree that if we had the functionality suggested by @Abdullahsab3's on https://github.com/apache/datafusion/issues/10368#issue-2277903243 > given a UTC timestamp, I would like to have that timestamp in local time of a given timezone We think we could get the right value out of `date_bin`. For example, If we had a function like `remove_timezone` that behaved like ```sql select remove_timezone("time in Brussels") +---------------------------+---------------------+ | time in Brussels | remove_timezone | +---------------------------+---------------------+ | 2024-04-30T23:30:00+02:00 | 2024-04-30T23:30:00 | | 2024-05-01T00:30:00+02:00 | 2024-05-01T00:30:00 | <-- timezone removed (no +02:00, but value not adjusted) | 2024-05-01T01:30:00+02:00 | 2024-05-01T01:30:00 | | 2024-05-01T02:00:00+02:00 | 2024-05-01T00:00:00 | | 2024-05-01T02:30:00+02:00 | 2024-05-01T02:30:00 | | 2024-05-01T12:30:00+02:00 | 2024-05-01T12:30:00 | | 2024-05-01T22:30:00+02:00 | 2024-05-01T22:30:00 | +---------------------------+---------------------+ ``` Note that this is different than `arrow_cast("time in Brussels", 'Timestamp(Nanosecond, None)')` because `arrow_cast` will adjust the timestamp values ```sql -- Times in brussels WITH t_brussels AS ( SELECT column1 AT TIME ZONE 'Europe/Brussels' as ts -- timestamp in specified timezone FROM t_utc ) SELECT ts as "time in Brussels", arrow_cast(ts, 'Timestamp(Nanosecond, None)') as arrow_cast FROM t_brussels; +---------------------------+---------------------+ | time in Brussels | arrow_cast | +---------------------------+---------------------+ | 2024-04-30T23:30:00+02:00 | 2024-04-30T21:30:00 | | 2024-05-01T00:30:00+02:00 | 2024-04-30T22:30:00 | <-- note this is now in 2024-04-30 not 2024-05-01 | 2024-05-01T01:30:00+02:00 | 2024-04-30T23:30:00 | | 2024-05-01T02:00:00+02:00 | 2024-05-01T00:00:00 | | 2024-05-01T02:30:00+02:00 | 2024-05-01T00:30:00 | | 2024-05-01T12:30:00+02:00 | 2024-05-01T10:30:00 | | 2024-05-01T22:30:00+02:00 | 2024-05-01T20:30:00 | +---------------------------+---------------------+ 7 row(s) fetched. Elapsed 0.003 seconds. ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org