Skip to content

Remove stored Union Nullability#8714

Merged
connortsui20 merged 3 commits into
developfrom
codex/remove-union-nullability
Jul 10, 2026
Merged

Remove stored Union Nullability#8714
connortsui20 merged 3 commits into
developfrom
codex/remove-union-nullability

Conversation

@connortsui20

@connortsui20 connortsui20 commented Jul 10, 2026

Copy link
Copy Markdown
Member

Summary

Tracking issue: #7882

A union has no independent parent validity. A row is null when its selected child is null, so the union's logical nullability is determined by its variants.

Storing the same information on DType::Union created two sources of truth and allowed the outer value to disagree with the variants. This change makes inconsistent union DTypes impossible.

The remaining question is how an operation such as mask should change a union's variants when it introduces nulls. That remains deferred and does not block the canonical sparse UnionArray.

The Arrow implementation notes and deferred operation scope are in this comment on #7882.

Changes

  • change DType::Union to store only UnionVariants
  • derive union nullability at runtime from the variant DTypes
  • name the non-zero-cost scan derived_nullability
  • leave with_nullability unchanged for unions instead of rewriting variant schemas
  • restrict union least-supertype coercion to identical variants for now
  • remove Union nullability from Serde, protobuf, and FlatBuffers

Supersedes #8713.

Comment on lines +71 to +73
names: [string];
dtypes: [DType];
type_ids: [byte]; // length must equal dtypes.len()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

should be fine to break this since nobody is using this yet

@connortsui20 connortsui20 force-pushed the codex/remove-union-nullability branch from f721143 to 30b2a25 Compare July 10, 2026 14:36
@connortsui20 connortsui20 added changelog/feature A new feature changelog/fix A bug fix and removed changelog/fix A bug fix labels Jul 10, 2026
FixedSizeList(edt, size, _) => FixedSizeList(Arc::clone(edt), *size, nullability),
Struct(sf, _) => Struct(sf.clone(), nullability),
Union(vs, _) => Union(vs.clone(), nullability),
Union(vs) => Union(vs.clone()),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So with_nullability now does nothing for Union. I think this is the correct semantics since it is similar for struct where it will not change child nullabilities?

@connortsui20 connortsui20 marked this pull request as ready for review July 10, 2026 14:44
@connortsui20

connortsui20 commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

Is there a way to override the flatc check here?

Edit: making changes

@vortex-data vortex-data deleted a comment from codspeed-hq Bot Jul 10, 2026
@connortsui20 connortsui20 force-pushed the codex/remove-union-nullability branch from 30b2a25 to d94c1ee Compare July 10, 2026 14:50
@connortsui20 connortsui20 enabled auto-merge (squash) July 10, 2026 14:51
@connortsui20 connortsui20 disabled auto-merge July 10, 2026 14:51
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
@connortsui20 connortsui20 changed the title Remove stored Union nullability Remove stored Union Nullability Jul 10, 2026
@connortsui20 connortsui20 added changelog/break A breaking API change and removed changelog/feature A new feature labels Jul 10, 2026
@connortsui20 connortsui20 force-pushed the codex/remove-union-nullability branch from d94c1ee to 5d215b5 Compare July 10, 2026 14:59
Comment thread .github/workflows/ci.yml Outdated
Comment on lines +639 to +641
if: >-
github.event_name != 'pull_request'
|| !contains(github.event.pull_request.labels.*.name, 'changelog/break')

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@robert3005 are you ok with this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we cannot do this

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

😢

@connortsui20 connortsui20 force-pushed the codex/remove-union-nullability branch from 5d215b5 to f535f8d Compare July 10, 2026 15:04
@vortex-data vortex-data deleted a comment from codspeed-hq Bot Jul 10, 2026
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
@connortsui20 connortsui20 force-pushed the codex/remove-union-nullability branch from f535f8d to e6e8eeb Compare July 10, 2026 15:11
@connortsui20 connortsui20 enabled auto-merge (squash) July 10, 2026 15:12
@robert3005

Copy link
Copy Markdown
Contributor

poke

@codspeed-hq

codspeed-hq Bot commented Jul 10, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚡ 1 improved benchmark
❌ 2 regressed benchmarks
✅ 1627 untouched benchmarks
⏩ 42 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation chunked_varbinview_into_canonical[(1000, 10)] 170 µs 206 µs -17.49%
Simulation compare_int_constant 268.4 µs 298.3 µs -10%
Simulation chunked_varbinview_opt_canonical_into[(100, 100)] 340.2 µs 305.9 µs +11.22%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing codex/remove-union-nullability (e6e8eeb) with develop (d96e4ad)

Open in CodSpeed

Footnotes

  1. 42 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@connortsui20 connortsui20 merged commit 357a4ba into develop Jul 10, 2026
70 of 72 checks passed
@connortsui20 connortsui20 deleted the codex/remove-union-nullability branch July 10, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/break A breaking API change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants