brimdata / zed

A novel data lake based on super-structured data
https://zed.brimdata.io/
BSD 3-Clause "New" or "Revised" License
1.38k stars 67 forks source link

Intentional early exit #5298

Open philrz opened 1 week ago

philrz commented 1 week ago

tl;dr

A user may want to craft a pipeline that intentionally stops processing the input stream when a particular condition is met.

Details

At the time this issue is being filed, Zed is at commit c1da204.

A user inquired in a recent community Slack thread:

Are head and tail the only two ways to terminate processing a stream? If I'm processing a potentially long stream of text data (-i line), and I know I want to stop processing after, say, an empty line comes through, I can't think of a way to do that.

Upon seeing this @mattnibs remarked:

Yeah, I’ve thought about having an exit operator that takes a Boolean expression and exits when the expression evaluates true.

chrismo commented 1 week ago

How would this work on a branch? (i.e. within a fork call, etc). I presume exit could just terminate the current branch?

mattnibs commented 1 week ago

@chrismo a fork will keep passing values to all non-closed branches.