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
6 changes: 6 additions & 0 deletions sqlglot/dialects/exasol.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,3 +417,9 @@ def dateadd_sql(self, expression: exp.DateAdd) -> str:
return self.function_fallback_sql(expression)

return self.func(f"ADD_{unit}S", expression.this, expression.expression)

# https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/rank.htm
def rank_sql(self, expression: exp.Rank) -> str:
if expression.args.get("expressions"):
self.unsupported("Exasol does not support arguments in RANK")
return self.func("RANK")
9 changes: 9 additions & 0 deletions tests/dialects/test_exasol.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ def test_aggregateFunctions(self):
},
)

self.validate_all(
"SELECT a, b, rank(b) OVER (ORDER BY b) FROM (VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1)) AS tab(a, b)",
write={
"exasol": "SELECT a, b, RANK() OVER (ORDER BY b) FROM (VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1)) AS tab(a, b)",
"databricks": "SELECT a, b, RANK(b) OVER (ORDER BY b NULLS LAST) FROM VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1) AS tab(a, b)",
"spark": "SELECT a, b, RANK(b) OVER (ORDER BY b NULLS LAST) FROM VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1) AS tab(a, b)",
},
)

def test_stringFunctions(self):
self.validate_identity(
"TO_CHAR(CAST(TO_DATE(date, 'YYYYMMDD') AS TIMESTAMP), 'DY') AS day_of_week"
Expand Down