Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions prqlc/prqlc/src/sql/std.sql.prql
Original file line number Diff line number Diff line change
Expand Up @@ -392,4 +392,10 @@ module snowflake {
# https://docs.snowflake.com/en/sql-reference/operators-arithmetic#division
@{binding_strength=11}
let div_f = l r -> s"({l} / {r:12})"

# Text functions
module text {
# https://docs.snowflake.com/en/sql-reference/functions-string
let length = column -> s"LENGTH({column:0})"
}
}
17 changes: 17 additions & 0 deletions prqlc/prqlc/tests/integration/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6622,6 +6622,23 @@ fn test_snowflake_row_number_with_explicit_sort() {
"#);
}

#[test]
fn test_snowflake_text_length_uses_length() {
// Snowflake should use LENGTH instead of CHAR_LENGTH
assert_snapshot!(compile_with_sql_dialect(r###"
from employees
select {
name_length = (name | text.length)
}
"###, sql::Dialect::Snowflake
).unwrap(), @r#"
SELECT
LENGTH("name") AS "name_length"
FROM
"employees"
"#);
}

#[test]
fn test_group_with_only_sort() {
// Issue #5092: group with only sort (no take) should not cause ICE.
Expand Down