Git Product home page Git Product logo

Comments (6)

mhilton avatar mhilton commented on June 19, 2024 1

In postgresql the AT TIME ZONE expression changes a TIMESTAMP WITH TIME ZONE value to TIMESTAMP WITHOUT TIME ZONE value at the wall-clock time in the requested time zone (see table 9.34).

In datafusion this expression casts from one TIMESTAMP WITH TIME ZONE to another TIMESTAMP WITH TIME ZONE with the time zone adjusted.

from datafusion.

jayzhan211 avatar jayzhan211 commented on June 19, 2024

See the result in Postgres

postgres=# set timezone to '+08';
SET
postgres=# select '2020-11-30T08:00:00.000Z'::timestamp at time zone 'Europe/Brussels';
        timezone        
------------------------
 2020-11-30 15:00:00+08
(1 row)

postgres=# set timezone to '+01';
SET
postgres=# select '2020-11-30T08:00:00.000Z'::timestamp at time zone 'Europe/Brussels';
        timezone        
------------------------
 2020-11-30 08:00:00+01
(1 row)

postgres=# set timezone to '+00';
SET
postgres=# select '2020-11-30T08:00:00.000Z'::timestamp at time zone 'Europe/Brussels';
        timezone        
------------------------
 2020-11-30 07:00:00+00
(1 row)

I think we should not return 9:00:00, because the local time for timezone +1 is 8:00:00.
If I understand correctly, the function you proposing is similar to the example above, but the timezone is given into the function?

so select to_local_time('2020-11-30T08:00:00.000Z'::timestamp, '+01'); should return 2020-11-30 08:00:00, select to_local_time('2020-11-30T08:00:00.000Z'::timestamp, '+00'); should return 2020-11-30 07:00:00 and likewise 2020-11-30 15:00:00 for '+08'

from datafusion.

jayzhan211 avatar jayzhan211 commented on June 19, 2024

btw, I think there might be some bug in datafusion, the behavior is unlike Postgres


statement ok
set datafusion.catalog.information_schema = true

statement ok
SET TIME ZONE = '+00:00'

query TT
SHOW TIMEZONE
----
datafusion.execution.time_zone +00:00

query P
select '2020-11-30T08:00:00.000Z'::timestamp at time zone 'Europe/Brussels';
----
2020-11-30T08:00:00+01:00

statement ok
SET TIME ZONE = '+01:00'

query P
select '2020-11-30T08:00:00.000Z'::timestamp at time zone 'Europe/Brussels';
----
2020-11-30T08:00:00+01:00

statement ok
SET TIME ZONE = '+08:00'

query P
select '2020-11-30T08:00:00.000Z'::timestamp at time zone 'Europe/Brussels';
----
2020-11-30T08:00:00+01:00

from datafusion.

Abdullahsab3 avatar Abdullahsab3 commented on June 19, 2024

Thanks for the response!

I think we should not return 9:00:00, because the local time for timezone +1 is 8:00:00.

I wonder whether it has to do with the at time zone operator. If we add at time zone 'UTC' in between for instance, we would be getting different results (in postgres):

select '2020-11-30T08:00:00.000Z'::timestamp at time zone 'UTC' at time zone 'Europe/Brussels';
---
2020-11-30 09:00:00.000000

This is the result I would expect

See: https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-ZONECONVERT
I think the at time zone operator behaviour is to consider the timestamp as a timezone-less timestamp (which I think means that the Z will be ignored)

Now that I think about it, it might be that what I am proposing is actually for the at time zone operator to have the same behaviour as postgres. I also think that something is not right with the at time zone operator in Datafusion

from datafusion.

alamb avatar alamb commented on June 19, 2024

I haven't read this ticket in detail yet, but there is a collection of other issues on #8282

from datafusion.

alamb avatar alamb commented on June 19, 2024

I have filed #10602 with a summary of how I understand the usecase of "how do we bin timesamps in timezones with daylight savings time correctly" and some ideas on how to proceed

from datafusion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.