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

Fix(doris): postgres interval type date function #4072

Closed
wants to merge 5 commits into from

Conversation

Toms1999
Copy link
Contributor

@Toms1999 Toms1999 commented Sep 6, 2024

Before you file an issue

  • Make sure you specify the "read" dialect eg. parse_one(sql, read="postgres")
  • Make sure you specify the "write" dialect eg. ast.sql(dialect="doris")
  • Check if the issue still exists on main:Couldn't find anything related

Fully reproducible code snippet

import sqlglot

sql = """SELECT NOW() - INTERVAL '1 YEAR + 1 MONTH'"""

print(sqlglot.transpile(sql ,read="postgres" , write="doris")[0]);

output

SELECT NOW() - INTERVAL '1 YEAR + 1 MONTH'

Expected output

SELECT NOW() - INTERVAL '1' YEAR - INTERVAL '1' MONTH

import sqlglot

sql = """SELECT NOW() - INTERVAL '1 YEAR - 1 MONTH'"""

print(sqlglot.transpile(sql ,read="postgres" , write="doris")[0]);

output

SELECT NOW() - INTERVAL '1 YEAR - 1 MONTH'

Expected output

SELECT NOW() - INTERVAL '1' YEAR + INTERVAL '1' MONTH

image

@tobymao tobymao closed this Sep 6, 2024
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

Successfully merging this pull request may close these issues.

2 participants