Skip to content

fix bugs in dot expressions with union-missings - #7478

Merged
mccanne merged 3 commits into
mainfrom
dot-union-missing
Oct 14, 2026
Merged

mccanne merged 3 commits into
mainfrom
dot-union-missing

Conversation

@mccanne

@mccanne mccanne commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

This commit fixes how dot expressions handle missing-field errors by recognizing the only place these come from are either from fields missing in a plain record or union-missings that are none::union fusion values. This code path is simple and elegant now and will be easier to maintain.

There is still a problem with fusion projections but this change hides that bug away from all our tests. We will fix this in a subsequent PR.

Fixes #7469

This commit fixes how dot expressions handle missing-field errors
by recognizing the only place these come from are either from
fields missing in a plain record or union-missings that are
none::union fusion values.  This code path is simple and elegant
now and will be easier to maintain.

There is still a problem with fusion projections but this change
hides that bug away from all our tests.  We will fix this in a
subsequent PR.

Fixes #7469
Comment thread vector/apply.go
Comment on lines +227 to +228
noneTag := findNone(union.Values())
if noneTag < 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.

Nit: I think the intention here would be clearer if you could see the length check.

Suggested change
noneTag := findNone(union.Values())
if noneTag < 0 {
noneTag := union.Typ.TagOf(super.TypeNone)
if noneTag < 0 || union.Values()[noneTag].Len() == 0 {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Values tags and type tags are not aligned

Comment thread vector/apply.go Outdated
if noneTag < 0 {
return vec
}
var pick, tags []uint32

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.

Nit: We usually call this thing index.

Suggested change
var pick, tags []uint32
var index, tags []uint32

Comment thread sio/jsonio/ztests/missing-none.yaml Outdated
---

script: |
super -f bsup -o in.bsup in.json

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.

Nit:

Suggested change
super -f bsup -o in.bsup in.json
super -o in.bsup in.json

Comment thread runtime/expr/dot.go Outdated
case *vector.Fusion:
return hasMissingUnion(vec.Values)
case *vector.Dynamic:
return slices.IndexFunc(vec.Values, hasMissingUnion) >= 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.

Suggested change
return slices.IndexFunc(vec.Values, hasMissingUnion) >= 0
return slices.ContainsFunc(vec.Values, hasMissingUnion)

@mccanne
mccanne merged commit c81680b into main Oct 14, 2026
2 checks passed
@mccanne
mccanne deleted the dot-union-missing branch October 14, 2026 22:38
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.

JSONBench q1 result contains downcast errors

2 participants