Skip to content

Commit 7f550f2

Browse files
Chore(optimizer): add annotation tests for NVL (#6207)
* add annotation tests for NVL * address comments
1 parent ef68075 commit 7f550f2

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tests/dialects/test_snowflake.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def test_snowflake(self):
6060
self.validate_identity("SELECT HEX_ENCODE('Hello World', 0)")
6161
self.validate_identity("SELECT NEXT_DAY('2025-10-15', 'FRIDAY')")
6262
self.validate_identity("SELECT NVL2(col1, col2, col3)")
63+
self.validate_identity("SELECT NVL(col1, col2)", "SELECT COALESCE(col1, col2)")
6364
self.validate_identity("SELECT CHR(8364)")
6465
self.validate_identity("SELECT COMPRESS('Hello World', 'ZLIB')")
6566
self.validate_identity("SELECT DECOMPRESS_BINARY('compressed_data', 'SNAPPY')")

tests/fixtures/optimizer/annotate_functions.sql

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,6 +2375,26 @@ VARCHAR;
23752375
NVL2(col1, col2, col3);
23762376
UNKNOWN;
23772377

2378+
# dialect: snowflake
2379+
NVL('hello', 'world');
2380+
VARCHAR;
2381+
2382+
# dialect: snowflake
2383+
NVL(tbl.int_col, 42);
2384+
INT;
2385+
2386+
# dialect: snowflake
2387+
NVL(tbl.date_col, CAST('2024-01-01' AS DATE));
2388+
DATE;
2389+
2390+
# dialect: snowflake
2391+
NVL(1, 3.14);
2392+
DOUBLE;
2393+
2394+
# dialect: snowflake
2395+
NVL(5::BIGINT, 2.71::FLOAT);
2396+
FLOAT;
2397+
23782398
# dialect: snowflake
23792399
NULLIFZERO(5);
23802400
INT;

0 commit comments

Comments
 (0)