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(parser, redshift): parse dateadd alias date_add #1995

Merged
merged 1 commit into from
Aug 4, 2023

Conversation

gafeol
Copy link
Contributor

@gafeol gafeol commented Aug 4, 2023

Redshift also supports using DATE_ADD as an alias of DATEADD. Right now, they both functions are parsed differently:

sql = "SELECT DATE_ADD('day', 1, date('2023-01-01'))"
sqlglot.transpile(sql, read='redshift', write='redshift')
> ["SELECT DATEADD(day, 1, 'day')"]

sql = "SELECT DATEADD('day', 1, date('2023-01-01'))"
sqlglot.transpile(sql, read='redshift', write='redshift')
> ["SELECT DATEADD(day, 1, DATE('2023-01-01'))

Added the same parser used on DATEADD to fix this difference.

Redshift also supports using `DATE_ADD` as an alias of `DATEADD`.
Right now, they both functions are parsed differently:

```
sql = "SELECT DATE_ADD('day', 1, date('2023-01-01'))"
sqlglot.transpile(sql, read='redshift', write='redshift')
> ["SELECT DATEADD(day, 1, 'day')"]

sql = "SELECT DATEADD('day', 1, date('2023-01-01'))"
sqlglot.transpile(sql, read='redshift', write='redshift')
> ["SELECT DATEADD(day, 1, DATE('2023-01-01'))
```

Added the same parser used on DATEADD to fix this difference.
@tobymao
Copy link
Owner

tobymao commented Aug 4, 2023

thanks for the pr! can you make it a function so we can DRY it up?

@georgesittas georgesittas merged commit e00d857 into tobymao:main Aug 4, 2023
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.

3 participants