Skip to content

Commit 3ba64b4

Browse files
committed
add explicit handling for empty slices
1 parent 92be769 commit 3ba64b4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

bigframes/core/rewrite/slices.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ def rewrite_slice(node: nodes.BigFrameNode):
7676
return node
7777

7878
slice_def = (node.start, node.stop, node.step)
79+
80+
# Handle empty slice cases exlicitly (e.g. [0:0])
81+
if (
82+
node.start is not None
83+
and node.stop is not None
84+
and node.start >= node.stop
85+
and (node.step is None or node.step > 0)
86+
):
87+
# Return empty result by filtering with impossible condition
88+
return slice_as_filter(node.child, node.start, node.start, node.step or 1)
89+
7990
# no-op (eg. df[::1])
8091
if slices.is_noop(slice_def, node.child.row_count):
8192
return node.child

0 commit comments

Comments
 (0)