From a33df054c1725ddcef160cd3a3850cb1c364c771 Mon Sep 17 00:00:00 2001 From: Matthew Nibecker Date: Mon, 19 Feb 2024 10:49:24 -0700 Subject: [PATCH] collect(): Do not ignore null values Closes #5039 --- docs/tutorials/schools.md | 7 +++---- runtime/sam/expr/agg/collect.go | 4 +--- runtime/sam/expr/agg/ztests/collect-untag-unions.yaml | 3 ++- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/tutorials/schools.md b/docs/tutorials/schools.md index daeacc4d3a..aeeeae318c 100644 --- a/docs/tutorials/schools.md +++ b/docs/tutorials/schools.md @@ -1013,7 +1013,8 @@ and produces Schools: [ "Auberry Elementary", "Balch Camp Elementary", - "Pine Ridge Elementary" + "Pine Ridge Elementary", + null (string) ] } { @@ -1023,9 +1024,7 @@ and produces "www.bigcreekschool.com" ], Schools: [ - "Big Creek Elementary" - ] -} + "Big Creek Elementary", ... ``` diff --git a/runtime/sam/expr/agg/collect.go b/runtime/sam/expr/agg/collect.go index 1877eb048b..030e31d8bb 100644 --- a/runtime/sam/expr/agg/collect.go +++ b/runtime/sam/expr/agg/collect.go @@ -16,9 +16,7 @@ type Collect struct { var _ Function = (*Collect)(nil) func (c *Collect) Consume(val zed.Value) { - if !val.IsNull() { - c.update(val) - } + c.update(val) } func (c *Collect) update(val zed.Value) { diff --git a/runtime/sam/expr/agg/ztests/collect-untag-unions.yaml b/runtime/sam/expr/agg/ztests/collect-untag-unions.yaml index b94ea627fe..8f1bb1b9f7 100644 --- a/runtime/sam/expr/agg/ztests/collect-untag-unions.yaml +++ b/runtime/sam/expr/agg/ztests/collect-untag-unions.yaml @@ -4,6 +4,7 @@ input: | 1((int64,string)) "foo"((time,string)) 0.5 + null(string) output: | - [1,"foo",0.5] + [1,"foo",0.5,null]