apache / apache/datafusion

Extract sql expression no longer is timezone aware

Open
#18,228 1 comment 0 reactions 1 assignee Claimed by @codetyri0n View on GitHub
bug
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Describe the bug

From the documentation on config_options.execution.[time_zone](https://github.com/apache/datafusion/blob/1f434dcdda227504cd4730a6c8bcad468b363983/datafusion/common/src/config.rs#L471) it looks like `Extract` in sql used to be aware of the system time zone however that looks to have been lost at some point. I am unable to determine when exactly but I suspect it was when that functionality was extracted/migrated [to use the date_part UDF](https://github.com/apache/datafusion/blob/d64b7c3b4b3f446c5626f73e59d61933da6656f0/datafusion/functions/src/datetime/planner.rs#L32).

The fix for this is likely to make date_part udf time zone aware in a similar manner that now, to_timestamp, etc are being updated.

I also was unable to find any slt tests that covered this - from what I could find the tests for `extract` only ever used +00:00 as the tz.

### To Reproduce

_No response_

### Expected behavior

extract(Hour from some_time) should likely be aware of configured timezone.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.