Skip to content

Commit fb066a6

Browse files
authored
fix(oracle)!: Decouple NVL() from COALESCE() (#3734)
* fix(oracle): Decouple NVL() from COALESCE() * Change parse_one() to validate_identity() Revert Snowflake
1 parent e5a53aa commit fb066a6

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

sqlglot/dialects/oracle.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class Parser(parser.Parser):
107107
"TO_TIMESTAMP": build_formatted_time(exp.StrToTime, "oracle"),
108108
"TO_DATE": build_formatted_time(exp.StrToDate, "oracle"),
109109
}
110+
FUNCTIONS.pop("NVL")
110111

111112
FUNCTION_PARSERS: t.Dict[str, t.Callable] = {
112113
**parser.Parser.FUNCTION_PARSERS,

tests/dialects/test_oracle.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ def test_oracle(self):
8686
"SELECT DISTINCT col1, col2 FROM table",
8787
)
8888
self.validate_identity(
89-
"SELECT * FROM T ORDER BY I OFFSET nvl(:variable1, 10) ROWS FETCH NEXT nvl(:variable2, 10) ROWS ONLY",
90-
"SELECT * FROM T ORDER BY I OFFSET COALESCE(:variable1, 10) ROWS FETCH NEXT COALESCE(:variable2, 10) ROWS ONLY",
89+
"SELECT * FROM T ORDER BY I OFFSET NVL(:variable1, 10) ROWS FETCH NEXT NVL(:variable2, 10) ROWS ONLY",
9190
)
91+
self.validate_identity("NVL(x, y)").assert_is(exp.Anonymous)
9292
self.validate_identity(
9393
"SELECT * FROM t SAMPLE (.25)",
9494
"SELECT * FROM t SAMPLE (0.25)",
@@ -189,13 +189,6 @@ def test_oracle(self):
189189
"spark": "SELECT CAST(NULL AS VARCHAR(2328)) AS COL1",
190190
},
191191
)
192-
self.validate_all(
193-
"NVL(NULL, 1)",
194-
write={
195-
"": "COALESCE(NULL, 1)",
196-
"oracle": "COALESCE(NULL, 1)",
197-
},
198-
)
199192
self.validate_all(
200193
"DATE '2022-01-01'",
201194
write={

0 commit comments

Comments
 (0)