Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions runtime/vam/expr/function/upcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package function

import (
"fmt"
"slices"

"github.com/brimdata/super"
samfunc "github.com/brimdata/super/runtime/sam/expr/function"
Expand Down Expand Up @@ -83,6 +82,9 @@ func (u *Upcast) upcast(vec vector.Any, to super.Type) vector.Any {
if vec.Type() == to && vec.Kind() != vector.KindFusion {
return vec
}
if vec.Len() == 0 {
return vector.NewEmpty(to)
}
switch vec := vec.(type) {
case *vector.Fusion:
return u.upcast(vec.Values, to)
Expand Down Expand Up @@ -181,16 +183,15 @@ func (u *Upcast) deunionAndUpcast(vec vector.Any, to super.Type) vector.Any {
if !ok {
return u.upcast(vec, to)
}
vecs := slices.Clone(d.Values)
for i, vec := range vecs {
if vec == nil || vec.Len() == 0 {
continue
}
vecs[i] = u.upcast(vecs[i], to)
vecs := make([]vector.Any, len(d.Values))
for i, vec := range d.Values {
vecs[i] = u.upcast(vec, to)
if vecs[i] == nil {
return nil
}
}
// All elements of vecs have type to so this should always return a
// vector with type to (and never a dynamic).
return vbuild.MergeSameTypesInDynamic(vector.NewDynamic(d.Tags, vecs))
}

Expand Down
3 changes: 0 additions & 3 deletions runtime/ztests/expr/function/defuse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,6 @@ output: *input

---

# Panics in vam.
runtime: sam

spq: fuse | defuse(this)

input: &input |
Expand Down
3 changes: 3 additions & 0 deletions vector/vbuild/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ func Merge(tags []uint32, vecs []vector.Any) vector.Any {
reverse := make([][]uint32, len(vecs))
var k uint32
for i, vec := range vecs {
if vec.Len() == 0 {
continue
}
b.Write(vec)
for range vec.Len() {
reverse[i] = append(reverse[i], k)
Expand Down
Loading