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

Regression of interval parsing #1503

Closed
alippai opened this issue Apr 29, 2023 · 7 comments
Closed

Regression of interval parsing #1503

alippai opened this issue Apr 29, 2023 · 7 comments

Comments

@alippai
Copy link

alippai commented Apr 29, 2023

select sum(x) over (partition by x order by y range between interval '1 days')

is parsed into:

SELECT
  SUM("x") OVER (PARTITION BY "x" ORDER BY "y" range BETWEEN INTERVAL '1' days AND CURRENT ROW)

instead of the previous (correct):

SELECT
  SUM("x") OVER (PARTITION BY "x" ORDER BY "y" range BETWEEN INTERVAL '1 days' AND CURRENT ROW)

Note the days

@tobymao
Copy link
Owner

tobymao commented Apr 29, 2023

what dialect is this an issue for?

@alippai
Copy link
Author

alippai commented Apr 29, 2023

I see #1410 now. I'm using the postgres dialect, I was checking for changes when upgrading sqlglot and noticed this odd syntax.

@tobymao
Copy link
Owner

tobymao commented Apr 29, 2023

are you sure this is valid postgres? i can't get it to parse in postgres 13

@alippai
Copy link
Author

alippai commented Apr 29, 2023

I use a postgresql derivation, it doesn't really matter.
Better example:

select interval '1 hour'

vs

select interval '1 hours'

The first is parsed correctly, the second gives:

select interval '1' hours

Which is not valid. Only:

select interval '1' hour

is valid postgresql syntax

@alippai
Copy link
Author

alippai commented Apr 29, 2023

(The first means select interval '1' as "hours")

@alippai
Copy link
Author

alippai commented Apr 29, 2023

Thanks!

@tobymao
Copy link
Owner

tobymao commented Apr 29, 2023

thanks for the report and the quick response to my questions!

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

2 participants