Skip to content

Commit f758cea

Browse files
authored
chore(exasol): transformed rank function, ignoring parameters (#6408)
* chore: custom transformed rank function in exasol ensuring parameters are ignored * chore(exasol): refactored implementation, ignoring arguments
1 parent 9ddae4d commit f758cea

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

sqlglot/dialects/exasol.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,3 +417,9 @@ def dateadd_sql(self, expression: exp.DateAdd) -> str:
417417
return self.function_fallback_sql(expression)
418418

419419
return self.func(f"ADD_{unit}S", expression.this, expression.expression)
420+
421+
# https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/rank.htm
422+
def rank_sql(self, expression: exp.Rank) -> str:
423+
if expression.args.get("expressions"):
424+
self.unsupported("Exasol does not support arguments in RANK")
425+
return self.func("RANK")

tests/dialects/test_exasol.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,15 @@ def test_aggregateFunctions(self):
218218
},
219219
)
220220

221+
self.validate_all(
222+
"SELECT a, b, rank(b) OVER (ORDER BY b) FROM (VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1)) AS tab(a, b)",
223+
write={
224+
"exasol": "SELECT a, b, RANK() OVER (ORDER BY b) FROM (VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1)) AS tab(a, b)",
225+
"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)",
226+
"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)",
227+
},
228+
)
229+
221230
def test_stringFunctions(self):
222231
self.validate_identity(
223232
"TO_CHAR(CAST(TO_DATE(date, 'YYYYMMDD') AS TIMESTAMP), 'DY') AS day_of_week"

0 commit comments

Comments
 (0)