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

Translation issue with dateadd #2835

Closed
achicoine-coveo opened this issue Jun 28, 2024 · 2 comments
Closed

Translation issue with dateadd #2835

achicoine-coveo opened this issue Jun 28, 2024 · 2 comments

Comments

@achicoine-coveo
Copy link

I initially opened the issue in sqlglot, but Toby pointed out using sqlglot directly works.
tobymao/sqlglot#3710

I'm running these versions:
sqlglot==25.3.3
sqlglotrs==0.2.8
sqlmesh==0.106.1

This model can be used to reproduce it:
sqlglot==25.3.3
sqlglotrs==0.2.8
sqlmesh==0.106.1

The project is configured to be the snowflake dialect.

The code renders like this in sqlmesh:
sqlmesh render bronze.dateadd --dialect duckdb
SELECT
CURRENT_DATE + INTERVAL -1 DAY AS "_col_0"

In sqlglot the transpile puts the -1 in parenthesis which makes it work:
import sqlglot
print(sqlglot.transpile("dateadd(day, -1, current_date::timestamp)", read="snowflake", write="duckdb"))

CAST(CURRENT_DATE AS TIMESTAMP) + INTERVAL (-1) DAY

@tobymao
Copy link
Contributor

tobymao commented Jun 28, 2024

tobymao/sqlglot#3714

@georgesittas
Copy link
Contributor

Fixed by linked sqlglot PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants