Skip to content

Commit 417f1e8

Browse files
feat(snowflake)!: annotate types for BITNOT (#6234)
1 parent fcf017c commit 417f1e8

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

sqlglot/dialects/snowflake.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ class Parser(parser.Parser):
635635
step=seq_get(args, 2),
636636
),
637637
"ARRAY_SORT": exp.SortArray.from_arg_list,
638+
"BITNOT": lambda args: exp.BitwiseNot(this=seq_get(args, 0)),
638639
"BITXOR": _build_bitwise(exp.BitwiseXor, "BITXOR"),
639640
"BIT_XOR": _build_bitwise(exp.BitwiseXor, "BITXOR"),
640641
"BITOR": _build_bitwise(exp.BitwiseOr, "BITOR"),

tests/dialects/test_snowflake.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,7 @@ def test_snowflake(self):
13451345
"snowflake": "EDITDISTANCE(col1, col2, 3)",
13461346
},
13471347
)
1348+
self.validate_identity("SELECT BITNOT(a)")
13481349
self.validate_identity("SELECT BITOR(a, b)")
13491350
self.validate_identity("SELECT BIT_OR(a, b)", "SELECT BITOR(a, b)")
13501351
self.validate_identity("SELECT BITOR(a, b, 'LEFT')")

tests/fixtures/optimizer/annotate_functions.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,14 @@ INT;
16551655
BIT_LENGTH(tbl.bin_col);
16561656
INT;
16571657

1658+
# dialect: snowflake
1659+
BITNOT(5);
1660+
INT;
1661+
1662+
# dialect: snowflake
1663+
BITNOT(tbl.bin_col);
1664+
BINARY;
1665+
16581666
# dialect: snowflake
16591667
BITOR(2, 4);
16601668
INT;

0 commit comments

Comments
 (0)