Skip to content

Commit 0dca57c

Browse files
committed
feat(snowflake): implement NthValue
1 parent c4cb75b commit 0dca57c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ibis/backends/snowflake/registry.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ def _map(_, op):
123123
)
124124

125125

126+
def _nth_value(t, op):
127+
if not isinstance(nth := op.nth, ops.Literal):
128+
raise TypeError(f"`nth` argument must be a literal Python int, got {type(nth)}")
129+
return sa.func.nth_value(t.translate(op.arg), nth.value + 1)
130+
131+
126132
_TIMESTAMP_UNITS_TO_SCALE = {"s": 0, "ms": 3, "us": 6, "ns": 9}
127133

128134
_SF_POS_INF = sa.func.to_double("Inf")
@@ -241,6 +247,7 @@ def _map(_, op):
241247
sa.func.parse_json(sa.func.get(t.translate(op.arg), op.field)),
242248
t.get_sqla_type(op.output_dtype),
243249
),
250+
ops.NthValue: _nth_value,
244251
}
245252
)
246253

@@ -250,7 +257,6 @@ def _map(_, op):
250257
ops.CumulativeAny,
251258
ops.CumulativeOp,
252259
ops.NTile,
253-
ops.NthValue,
254260
# ibis.expr.operations.array
255261
ops.ArrayRepeat,
256262
ops.Unnest,

0 commit comments

Comments
 (0)