prql
prql copied to clipboard
Intervals broken for Postgres
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
^
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.
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;
Closed by https://github.com/PRQL/prql/pull/1649. If other dialects have other formats which aren't covered, let's reopen