Skip to content

add sum_type() function to compute a sum type from a map{string:type} - #7557

Merged
mccanne merged 5 commits into
mainfrom
sum_type
Oct 29, 2026
Merged

mccanne merged 5 commits into
mainfrom
sum_type

Conversation

@mccanne

@mccanne mccanne commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread runtime/expr/function/sumtype.go Outdated
Comment on lines +17 to +20
switch vec.Kind() {
case vector.KindError, vector.KindNull:
return vec
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catch?

Comment on lines +28 to +32
b := vector.NewDynamicValueBuilder()
for i := range vec.Len() {
out := s.call(vec, i)
b.Write(vector.ValueAt(nil, out, 0))
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serializing a slot, building a one-element vector from the serialization, serializing that element, and then writing the serialization to a vector builder inside a loop is goofy. Just return a super.Value from call.

Suggested change
b := vector.NewDynamicValueBuilder()
for i := range vec.Len() {
out := s.call(vec, i)
b.Write(vector.ValueAt(nil, out, 0))
}
b := vector.NewDynamicValueBuilder()
var sb scode.Builder
for i := range vec.Len() {
b.Write(s.call(&sb, vec, i))
}

@mccanne
mccanne merged commit 760f09c into main Oct 29, 2026
4 checks passed
@mccanne
mccanne deleted the sum_type branch October 29, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants