Skip to content

Commit adbf956

Browse files
feat(snowflake): add support for TRIM function
1 parent 164fec1 commit adbf956

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

sqlglot/dialects/snowflake.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,10 @@ class Snowflake(Dialect):
500500
**Dialect.ANNOTATORS,
501501
**{
502502
expr_type: lambda self, e: self._annotate_by_args(e, "this")
503-
for expr_type in (exp.Reverse,)
503+
for expr_type in (
504+
exp.Reverse,
505+
exp.Trim,
506+
)
504507
},
505508
}
506509

tests/fixtures/optimizer/annotate_functions.sql

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,6 +1559,30 @@ BINARY;
15591559
REVERSE(NULL);
15601560
NULL;
15611561

1562+
# dialect: snowflake
1563+
TRIM('hello world');
1564+
VARCHAR;
1565+
1566+
# dialect: snowflake
1567+
TRIM('hello world', 'hello');
1568+
VARCHAR;
1569+
1570+
# dialect: snowflake
1571+
TRIM(tbl.bin_col);
1572+
BINARY;
1573+
1574+
# dialect: snowflake
1575+
TRIM(tbl.bin_col, tbl.bin_col);
1576+
BINARY;
1577+
1578+
# dialect: snowflake
1579+
TRIM(tbl.str_col);
1580+
TEXT;
1581+
1582+
# dialect: snowflake
1583+
TRIM(tbl.str_col, tbl.str_col);
1584+
TEXT;
1585+
15621586
--------------------------------------
15631587
-- T-SQL
15641588
--------------------------------------

0 commit comments

Comments
 (0)