From c9eb91f38b833ab628b113486f765135c3b58961 Mon Sep 17 00:00:00 2001 From: Noah Treuhaft Date: Tue, 2 Jun 2026 14:39:50 -0400 Subject: [PATCH] vam: handle error(fusion(...)) in defuse() --- runtime/vam/expr/function/defuse.go | 12 ++++++++++++ runtime/ztests/expr/function/defuse.yaml | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/runtime/vam/expr/function/defuse.go b/runtime/vam/expr/function/defuse.go index 16f3cd258..e453b0c73 100644 --- a/runtime/vam/expr/function/defuse.go +++ b/runtime/vam/expr/function/defuse.go @@ -52,6 +52,8 @@ func (d *defuse) eval(in vector.Any) vector.Any { vecs = append(vecs, d.eval(vec)) } return vector.NewDynamic(dynamic.Tags, vecs) + case vector.KindError: + return d.defuseError(in) case vector.KindFusion: fusion := vector.PushView(in).(*vector.Fusion) return d.downcast.call(fusion.Values, fusion.Subtypes.Types()) @@ -157,3 +159,13 @@ func (d *defuse) defuseMap(in vector.Any) vector.Any { } return vector.NewDynamic(tags, vecs) } + +func (d *defuse) defuseError(in vector.Any) vector.Any { + errVec := vector.PushView(in).(*vector.Error) + valsVec := d.eval(errVec.Vals) + return vector.Apply(vector.ApplyNone, func(vecs ...vector.Any) vector.Any { + vec := vecs[0] + typ := d.sctx.LookupTypeError(vec.Type()) + return vector.NewError(typ, vec) + }, valsVec) +} diff --git a/runtime/ztests/expr/function/defuse.yaml b/runtime/ztests/expr/function/defuse.yaml index e82c3fe2d..b278f71a0 100644 --- a/runtime/ztests/expr/function/defuse.yaml +++ b/runtime/ztests/expr/function/defuse.yaml @@ -202,6 +202,16 @@ output: *input spq: fuse | defuse(this) +input: &input | + error("a") + error(0)::(null|error(int64)) + +output: *input + +--- + +spq: fuse | defuse(this) + input: &input | 1::(int64|null)