DATE_ADD(date, INTERVAL <expr> <part>) where <expr> is not a literal produces invalid DuckDB SQL: the interval expression is emitted without parentheses, and a nested function inside it is not transpiled.
Version: @polyglot-sql/sdk 0.12.1, DuckDB 1.5.5
Repro 1: column reference
transpile(
"SELECT DATE_ADD(DATE '2026-01-01', INTERVAL n MONTH) AS d FROM (SELECT 2 AS n)",
Dialect.BigQuery,
Dialect.DuckDB,
).sql[0];
Actual:
SELECT CAST('2026-01-01' AS DATE) + INTERVAL n MONTH AS d FROM (SELECT 2 AS n)
DuckDB: Parser Error: syntax error at or near "MONTH"
Expected: ... + INTERVAL (n) MONTH ..., which DuckDB accepts and returns 2026-03-01.
Repro 2: nested DATE_DIFF
transpile(
"SELECT DATE_ADD(DATE '2026-01-01', INTERVAL DATE_DIFF(DATE '2026-03-15', DATE '2026-01-01', MONTH) MONTH) AS d",
Dialect.BigQuery,
Dialect.DuckDB,
).sql[0];
Actual:
SELECT CAST('2026-01-01' AS DATE) + INTERVAL DATE_DIFF(CAST('2026-03-15' AS DATE), CAST('2026-01-01' AS DATE), MONTH) MONTH AS d
DuckDB: Parser Error: syntax error at or near "("
Besides the missing parentheses, the inner DATE_DIFF keeps BigQuery argument order and syntax. At top level the same call is transpiled correctly to DATE_DIFF('MONTH', CAST('2026-01-01' AS DATE), CAST('2026-03-15' AS DATE)), so the interval's inner expression seems to skip the dialect transforms.
Expected:
SELECT CAST('2026-01-01' AS DATE) + INTERVAL (DATE_DIFF('MONTH', CAST('2026-01-01' AS DATE), CAST('2026-03-15' AS DATE))) MONTH AS d
DATE_ADD(date, INTERVAL <expr> <part>)where<expr>is not a literal produces invalid DuckDB SQL: the interval expression is emitted without parentheses, and a nested function inside it is not transpiled.Version:
@polyglot-sql/sdk0.12.1, DuckDB 1.5.5Repro 1: column reference
Actual:
DuckDB:
Parser Error: syntax error at or near "MONTH"Expected:
... + INTERVAL (n) MONTH ..., which DuckDB accepts and returns2026-03-01.Repro 2: nested
DATE_DIFFActual:
DuckDB:
Parser Error: syntax error at or near "("Besides the missing parentheses, the inner
DATE_DIFFkeeps BigQuery argument order and syntax. At top level the same call is transpiled correctly toDATE_DIFF('MONTH', CAST('2026-01-01' AS DATE), CAST('2026-03-15' AS DATE)), so the interval's inner expression seems to skip the dialect transforms.Expected: