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

Intervals broken for Postgres #1251

Closed
mklopets opened this issue Dec 11, 2022 · 3 comments
Closed

Intervals broken for Postgres #1251

mklopets opened this issue Dec 11, 2022 · 3 comments
Labels

Comments

@mklopets
Copy link
Collaborator

mklopets commented Dec 11, 2022

prql dialect:postgres

from account
select [day_after_creation = created_at + 1days]

Postgres seems to require quotes around intervals:

SELECT
-  created_at + INTERVAL 1 DAY AS day_after_creation <--------- current output, will fail in postgres
+  created_at + INTERVAL '1 DAY' AS day_after_creation
FROM
  account

Error thrown:

Query 1 ERROR: ERROR:  syntax error at or near "1"
LINE 2:   created_at + INTERVAL 1 DAY AS day_after_creation
                                ^
@max-sixty
Copy link
Member

Ah, interesting. It looks like BQ doesn't: https://cloud.google.com/bigquery/docs/reference/standard-sql/interval_functions

Do you happen to know how common this is? I'd be happy to implement this if we had an idea of which dialects should do which.

@mklopets
Copy link
Collaborator Author

Unfortunately I don't have much experience with different dialects handling this. It looks like BigQuery and MySQL require no quotes, and Postgres requires one of the following two:

select now() + interval '1 month';
select now() + interval '1' month;

@max-sixty
Copy link
Member

Closed by #1649. If other dialects have other formats which aren't covered, let's reopen

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

No branches or pull requests

2 participants