Skip to content

Conversation

@codetyri0n
Copy link
Contributor

Which issue does this PR close?

Closes #18228

What changes are included in this PR?

The PR supports the enabling of timezone as an execution config and also recognises proper and improper timezone offsets (HH:MM) with the timestamp.

Are these changes tested?

Yes (slt)

Are there any user-facing changes?

Yes, users will be able to query extract expression with the enablement of the timezone execution config.

@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Nov 11, 2025
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Nov 11, 2025
@codetyri0n
Copy link
Contributor Author

codetyri0n commented Nov 11, 2025

@martin-g @Omega359 This PR is a direct port of #18417 which got really messy (my apologies 🥲) due to a whole lot of unwanted commits. Closed that so that we could have a clean PR.

This contains the commit which addressed @martin-g thoughts for :

  1. handling offsets that included tz such as +02:30 and the subsequent test cases.
  2. Robust test cases such as check for change in DAY
  3. minor error handling suggestions and tweaks.
  4. refactor of a common function - implemented in mod.rs as a helper function and correspondingly used in to_local_time and date_part files.

Improvements that could be made for future releases:

  1. Named timezone support ('Europe/Brussels' , 'Asia/Beijing' etc) that I was unclear on how to carry forward with.

Lmk wdyt (my apologies again for the messy closure and reopening of a separate PR for this)

EXTRACT(DAY FROM TIMESTAMP '2023-10-30 18:20:59-07:00'),
EXTRACT(DAY FROM TIMESTAMP '2023-10-30 07:20:59+12:00');
----
2 31 29
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests for New Year Eve:

Suggested change
2 31 29
2 31 29
query IIII
SELECT EXTRACT(YEAR FROM TIMESTAMP '2023-12-31 18:20:59-08:45'),
EXTRACT(MONTH FROM TIMESTAMP '2023-12-31 18:20:59-08:45'),
EXTRACT(DAY FROM TIMESTAMP '2023-12-31 18:20:59-08:45'),
EXTRACT(HOUR FROM TIMESTAMP '2023-12-31 18:20:59-08:45'),
EXTRACT(HOUR FROM TIMESTAMP '2023-12-31 18:20:59-08:45'),
EXTRACT(SECOND FROM TIMESTAMP '2023-12-31 18:20:59-08:45');
----
2024 01 01 03 05 59
query V
SELECT EXTRACT(YEAR FROM TIMESTAMP '2024-01-01 03:05:59+08:45'),
EXTRACT(MONTH FROM TIMESTAMP '2024-01-01 03:05:59+08:45'),
EXTRACT(DAY FROM TIMESTAMP '2024-01-01 03:05:59+08:45'),
EXTRACT(HOUR FROM TIMESTAMP '2024-01-01 03:05:59+08:45'),
EXTRACT(HOUR FROM TIMESTAMP '2024-01-01 03:05:59+08:45'),
EXTRACT(SECOND FROM TIMESTAMP '2024-01-01 03:05:59+08:45');
----
2023 12 31 18 20 59

I hope I got them right! :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for adding this scenario! I have committed with minor tweaks with the right test case format for slt : )
(the characters after 'query' tells us the type and rows returned)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract sql expression no longer is timezone aware

2 participants