Skip to content

fix(array): preserve result nullability when simplifying and/or/zip - #10286

Merged
robert3005 merged 2 commits into
vortex-data:developfrom
jackylee-ch:fix/simplify-preserve-nullability
Oct 4, 2026
Merged

robert3005 merged 2 commits into
vortex-data:developfrom
jackylee-ch:fix/simplify-preserve-nullability

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

What

Literal simplification could turn a well-typed nullable expression into a
non-nullable one. The and/or annihilator and identity rules returned a fresh
non-nullable bool literal or a bare child, and the zip literal-mask rule returned
the selected branch — none retaining the nullability that binding had inferred.
Optimizing e.g. and(root(), lit(false)) over a nullable root flipped bool? to
bool, so the optimized plan advertised a narrower schema than the bound
expression.

Fix

Coerce each simplified result back to the bound expression's dtype, so the
optimized plan keeps the inferred result schema. The regression cases are the
ones from the issue.

Fixes #10009

AI assistance

Prepared with AI assistance; I have reviewed and verified the change.

Literal simplification could turn a well-typed nullable expression into a
non-nullable one: the and/or annihilator and identity rules returned a fresh
non-nullable literal or a bare child, and the zip literal-mask rule returned the
selected branch, none of them retaining the nullability binding had inferred.

Coerce each simplified result back to the bound expression's dtype, so the
optimized plan keeps the same result schema. The regression cases come from the
issue.

Fixes vortex-data#10009

Signed-off-by: jackylee-ch <[email protected]>
Comment thread vortex-array/src/scalar_fn/fns/binary/mod.rs Outdated
Build the annihilator literal and widen the identity child to the inferred
result nullability inside each arm, instead of casting the whole result
afterwards, as suggested in review.

Signed-off-by: jackylee-ch <[email protected]>
@robert3005 robert3005 added the changelog/fix A bug fix label Oct 4, 2026
@robert3005
robert3005 enabled auto-merge (squash) October 4, 2026 20:04
@robert3005
robert3005 merged commit b127616 into vortex-data:develop Oct 4, 2026
140 of 144 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

and, or, and zip literal simplification changes the inferred result nullability

2 participants