Comments (6)
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.
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.
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.
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.
I haven't read this ticket in detail yet, but there is a collection of other issues on #8282
from datafusion.
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)
- Support extracting `Int8`, `Int16`, `Int32` statistics from Parquet Data Pages HOT 2
- Do we need to escape search string as it's used in regexp? Wondering what's the result of `contains("abcdefg", ".*")` HOT 5
- Add a benchmark for extracting parquet data page statistics HOT 1
- Push down filters below `Unnest` in sub queries HOT 7
- Convert `Average` to UDAF HOT 1
- Convert `Min` and `Max` to UDAF HOT 2
- Convert `Hyperloglog` to UDAF HOT 3
- Support extracting Float{16, 32, 64} statistics from Parquet Data Pages
- Support extracting UInt{8, 16, 32, 64} statistics from Parquet Data Pages
- DataFusion weekly project plan (Andrew Lamb) - June 17, 2024
- Timezone `UTC` is not considered equal to `+00:00` HOT 5
- Create a branch for StringView / BinaryView development HOT 1
- Change `StatisticsConverter::row_group_counts` to return `None` for non existent columns in parquet files HOT 1
- Complete Possible Join Type Handling for EmptyRelation Propagation Rule HOT 2
- Presentation about DataFusion at Microsoft GSL (Grey Systems Lab)
- Conditionally allow to keep partition_by columns when using PARTITIONED BY HOT 1
- Inconsistent behavior in HashJoin Projections HOT 1
- regen.sh is failing in Ubuntu when working with recommended version of protoc
- Implement `DynamicTableProvider` in DataFusion Core HOT 2
- Open Variant Type for semi-structured data HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datafusion.