Skip to content

Commit

Permalink
switch: Propagate batch variables (#5058)
Browse files Browse the repository at this point in the history
Fix issue with switch op where batch variables where not getting
propagated to newly created batches.

Closes #5031
  • Loading branch information
mattnibs committed Mar 1, 2024
1 parent 36b0d26 commit 1c992fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion runtime/sam/op/switcher/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (s *Selector) Forward(router *op.Router, batch zbuf.Batch) bool {
// outgoing batch so we don't send these slices
// through GC.
batch.Ref()
out := zbuf.NewArray(c.vals)
out := zbuf.NewBatch(batch, c.vals)
c.vals = nil
if ok := router.Send(c.route, out, nil); !ok {
return false
Expand Down
12 changes: 12 additions & 0 deletions runtime/sam/op/switcher/ztests/switch-vars.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
zed: |
over this with foo = {foo:"bar"} => (
switch (
case x % 2 == 0 => yield {x, ...foo}
)
)
input: "[{x:1},{x:2},{x:3},{x:4}]"

output: |
{x:2,foo:"bar"}
{x:4,foo:"bar"}

0 comments on commit 1c992fd

Please sign in to comment.