Skip to content

Commit 0984dc4

Browse files
authored
fix: Snowflake interval quoting style (#5604)
1 parent b957950 commit 0984dc4

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

prqlc/prqlc/src/sql/dialect.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,12 @@ impl DialectHandler for SnowflakeDialect {
613613
false
614614
}
615615

616+
fn interval_quoting_style(&self, _dtf: &DateTimeField) -> IntervalQuotingStyle {
617+
// Snowflake requires quotes around value and unit together
618+
// https://docs.snowflake.com/en/sql-reference/data-types-datetime#interval-constants
619+
IntervalQuotingStyle::ValueAndUnitQuoted
620+
}
621+
616622
fn requires_order_by_in_window_function(&self) -> bool {
617623
// https://docs.snowflake.com/en/sql-reference/functions/row_number
618624
// ROW_NUMBER() requires ORDER BY in window specification

prqlc/prqlc/tests/integration/sql.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,6 +1591,20 @@ fn test_interval() {
15911591
FROM
15921592
projects
15931593
"#);
1594+
1595+
let query = r###"
1596+
prql target:sql.snowflake
1597+
1598+
from projects
1599+
derive first_check_in = start + 10days
1600+
"###;
1601+
assert_snapshot!((compile(query).unwrap()), @r#"
1602+
SELECT
1603+
*,
1604+
"start" + INTERVAL '10 DAY' AS "first_check_in"
1605+
FROM
1606+
"projects"
1607+
"#);
15941608
}
15951609

15961610
#[test]

0 commit comments

Comments
 (0)