Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): introduce Timestamp Simplify rule to handle timezone #901

Merged
merged 3 commits into from
Nov 12, 2024

Conversation

goldmedal
Copy link
Contributor

@goldmedal goldmedal commented Nov 12, 2024

Description

We will simplify the timestamp literal when planning SQL to support the complex timezone issues in the different data sources. Something like

  • MSSQL only accepts the time zone offset.
  • Clikchouse only accepts the name of the time zone.
  • BigQuery has timestamp (impacted by timezone) and Datetime (non-impacted by timezone).

To handle them, Wren Core will convert all of the time zone literals to UTC, which is how other databases process the timestamp with the time zone literal.

Powered by DataFusion, both the offset and the timezone name are allowed. It can also handle the DST issue.

How the SQL transformed

When you input a SQL like

select timestamp '2011-01-01 18:00:00 Asia/Taipei'

The planned SQL will be

SELECT CAST('2011-01-01 10:00:00' AS TIMESTAMP)

Then, the dialect will be if the dialect is BigQuery.

SELECT CAST('2011-01-01 10:00:00' AS DATETIME)

@github-actions github-actions bot added core ibis rust Pull requests that update Rust code python Pull requests that update Python code labels Nov 12, 2024
@goldmedal goldmedal changed the title feature(core): introduce Timestamp Simplify rule to handle timezone feat(core): introduce Timestamp Simplify rule to handle timezone Nov 12, 2024
@goldmedal goldmedal marked this pull request as ready for review November 12, 2024 08:31
@grieve54706 grieve54706 added this to the 0.11.3 milestone Nov 12, 2024
Copy link
Contributor

@grieve54706 grieve54706 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the helpful feature.

@grieve54706 grieve54706 merged commit 4e333ce into Canner:main Nov 12, 2024
19 checks passed
@goldmedal goldmedal deleted the feature/session-timezone branch November 13, 2024 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core ibis python Pull requests that update Python code rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants