Skip to content

Commit

Permalink
feat(pyspark): implement nth_value
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and kszucs committed May 23, 2022
1 parent 1bf2842 commit abb559d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ibis/backends/pyspark/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,14 @@ def compile_last_value(t, expr, scope, timecontext, **kwargs):
return F.last(src_column)


@compiles(ops.NthValue)
def compile_nth_value(t, expr, scope, timecontext, **kwargs):
op = expr.op()
src_column = t.translate(op.arg, scope, timecontext)
nth = t.translate(op.nth, scope, timecontext, raw=True)
return F.nth_value(src_column, nth + 1)


@compiles(ops.RowNumber)
def compile_row_number(t, expr, scope, timecontext, **kwargs):
return F.row_number()
Expand Down

0 comments on commit abb559d

Please sign in to comment.