Skip to content

Commit

Permalink
chore(sqlglot): constant fold the nth_value offset if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Dec 1, 2023
1 parent 9e45de7 commit 35781e3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ibis/backends/base/sqlglot/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ def one_to_zero_index(_, **__):

@replace(ops.NthValue)
def add_one_to_nth_value_input(_, **__):
return _.copy(nth=ops.Add(_.nth, 1))
if isinstance(_.nth, ops.Literal):
nth = ops.Literal(_.nth.value + 1, dtype=_.nth.dtype)
else:
nth = ops.Add(_.nth, 1)
return _.copy(nth=nth)


@public
Expand Down

0 comments on commit 35781e3

Please sign in to comment.