Skip to content

Commit

Permalink
chore(clickhouse/flink/pyspark): handle zero-based indexing for ntile
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Oct 13, 2023
1 parent ec96c6d commit 3932785
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ibis/backends/flink/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def _window(translator: ExprTranslator, op: ops.Node) -> str:
arg_formatted = translator.translate(func.__window_op__)
result = f"{arg_formatted} {window_formatted}"

if isinstance(func, ops.RankBase):
if isinstance(func, (ops.RankBase, ops.NTile)):
return f"({result} - 1)"
else:
return result
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/pyspark/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ def compile_window_function(t, op, **kwargs):

result = t.translate(func, **kwargs, aggcontext=aggcontext).over(pyspark_window)

if isinstance(func, ops.RankBase):
if isinstance(func, (ops.RankBase, ops.NTile)):
# result must be cast to long type for Rank / RowNumber
return result.astype("long") - 1
else:
Expand Down

0 comments on commit 3932785

Please sign in to comment.