Skip to content

add support for Optional/None values to vector/vam#6700

Merged
mccanne merged 3 commits intomainfrom
vector-none
Mar 6, 2026
Merged

add support for Optional/None values to vector/vam#6700
mccanne merged 3 commits intomainfrom
vector-none

Conversation

@mccanne
Copy link
Collaborator

@mccanne mccanne commented Mar 6, 2026

This commit changes the fields of vector.Record back to vector.Any and introduces the concept of vector.Optional and vector.None. An Optional is simply a two-typed Dynamic of the original values plus the nones where the nones are represnted by vector.None which wraps a vector.Error("missing"). This means that None expresses itself as Missing when referenced unless asserted to None and treated otherwise.

There is also a performance issue in that we always load tags of Optionals when reading optional fields in vcache and we always compute the tags from the runlens in recordbuidler. In a future PR, we will compute the tags on demand under a lock.

There are still problems in both sam/vam with put/cut and problems in vam with None turning into Missing in aggregate functions. These issues will be addressed in subsequent PRs.

mccanne added 2 commits March 5, 2026 18:10
This commit changes the fields of vector.Record back to vector.Any
and introduces the concept of vector.Optional and vector.None.
An Optional is simply a two-typed Dynamic of the original values
plus the nones where the nones are represnted by vector.None which
wraps a vector.Error("missing").  This means that None expresses
itself as Missing when referenced unless asserted to None and
treated otherwise.

There is also a performance issue in that we always load tags
of Optionals when reading optional fields in vcache and we always
compute the tags from the runlens in recordbuidler.  In a future PR,
we will compute the tags on demand under a lock.

There are still problems in both sam/vam with put/cut and
problems in vam with None turning into Missing in aggregate functions.
These issues will be addressed in subsequent PRs.
}

func (u *unionBuilder) Build() Any {
func (u *unionBuilder) Build(sctx *super.Context) Any {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: If the argument isn't being used we typically do this but whateves:

Suggested change
func (u *unionBuilder) Build(sctx *super.Context) Any {
func (u *unionBuilder) Build(_ *super.Context) Any {

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's used here in the recursive call...

vector/record.go Outdated
return &Optional{NewDynamic(tags, []Any{vec, &None{NewMissing(sctx, noneLen)}})}
}

// An Optional value is a special Dynamic that has two tags comprosing the
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// An Optional value is a special Dynamic that has two tags comprosing the
// An Optional value is a special Dynamic that has two tags comprising the

@mccanne mccanne merged commit 9b6daa7 into main Mar 6, 2026
2 checks passed
@mccanne mccanne deleted the vector-none branch March 6, 2026 20:55
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