From af5d72fe178c48be07404357ee164710c0ddcba6 Mon Sep 17 00:00:00 2001 From: Noah Treuhaft Date: Mon, 16 Dec 2024 13:59:29 -0500 Subject: [PATCH] Fix EOS handling in vector summarize operator The summarize operator doesn't reset itself upon receives EOS from its parent, preventing it from working properly inside a scoped over operator (i.e., "over x => (summarize ...)"). Fix that. --- runtime/vam/op/summarize/summarize.go | 3 ++- .../ztests/bare-scoped.yaml => ztests/op/over-summarize.yaml} | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) rename runtime/{sam/op/traverse/ztests/bare-scoped.yaml => ztests/op/over-summarize.yaml} (88%) diff --git a/runtime/vam/op/summarize/summarize.go b/runtime/vam/op/summarize/summarize.go index 2bb2b9d28b..2d4aac9f47 100644 --- a/runtime/vam/op/summarize/summarize.go +++ b/runtime/vam/op/summarize/summarize.go @@ -63,7 +63,7 @@ func (s *Summarize) Pull(done bool) (vector.Any, error) { for _, t := range s.tables { s.results = append(s.results, t) } - s.tables = nil + clear(s.tables) return s.next(), nil } var keys, vals []vector.Any @@ -124,6 +124,7 @@ func (s *Summarize) isCountByString(keyTypes []super.Type) bool { func (s *Summarize) next() vector.Any { if len(s.results) == 0 { + s.results = nil return nil } t := s.results[0] diff --git a/runtime/sam/op/traverse/ztests/bare-scoped.yaml b/runtime/ztests/op/over-summarize.yaml similarity index 88% rename from runtime/sam/op/traverse/ztests/bare-scoped.yaml rename to runtime/ztests/op/over-summarize.yaml index ecb92a8e65..e84372ed4a 100644 --- a/runtime/sam/op/traverse/ztests/bare-scoped.yaml +++ b/runtime/ztests/op/over-summarize.yaml @@ -1,5 +1,7 @@ zed: over a => (sum(this)) +vector: true + input: | {a:null([int64])} {a:[6,5,4]}