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
1 change: 1 addition & 0 deletions sqlglot/parsers/databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class DatabricksParser(SparkParser):

FUNCTIONS = {
**SparkParser.FUNCTIONS,
"IFF": exp.If.from_arg_list,
"GETDATE": exp.CurrentTimestamp.from_arg_list,
"DATEADD": build_date_delta(exp.DateAdd),
"DATE_ADD": build_date_delta(exp.DateAdd),
Expand Down
11 changes: 11 additions & 0 deletions tests/dialects/test_databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,17 @@ def test_overlay(self):
"SELECT OVERLAY('Spark SQL' PLACING 'ANSI ' FROM 7 FOR 0)",
)

def test_iff(self):
# IFF is a synonym for IF in Databricks; it normalizes to IF on output
self.validate_all(
"SELECT IF(x > 0, 'positive', 'non-positive')",
read={"databricks": "SELECT IFF(x > 0, 'positive', 'non-positive')"},
write={
"databricks": "SELECT IF(x > 0, 'positive', 'non-positive')",
"snowflake": "SELECT IFF(x > 0, 'positive', 'non-positive')",
},
)

def test_declare(self):
self.validate_identity("DECLARE VAR x INT", "DECLARE x INT")
self.validate_identity("DECLARE x INT")
Expand Down
Loading