Canner / wren-engine

🤖 The semantic engine for LLMs, bringing semantic context to AI agents. 🔥
https://getwren.ai/oss
Apache License 2.0
129 stars 34 forks source link

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

Closed goldmedal closed 5 days ago

goldmedal commented 6 days ago

Description

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

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)