Skip to content

Change extension dtype nullability without validating again - #11012

Open
connortsui20 wants to merge 2 commits into
developfrom
ct/ext-types/dtype-invariants
Open

connortsui20 wants to merge 2 commits into
developfrom
ct/ext-types/dtype-invariants

Conversation

@connortsui20

@connortsui20 connortsui20 commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Summary

take and mask can make an extension array nullable, while min_max builds non-null result dtypes. These operations need to change nullability without failing. Previously, ExtDType::with_nullability called the plugin validator again and panicked if it returned an error.

An extension type must accept either top-level nullability, so an already valid dtype can be reused with that flag changed. with_nullability now relies on this contract instead of validating again.

Changes

Keeps metadata and storage types intact when changing nullability. Also fixes erased dtype Debug output, which wrote metadata before the struct and displayed metadata: Ok(()) in its place.

Regression tests cover both nullabilities, validation call counts, and compact and pretty Debug output. Checks for the style cleanup are left to CI.

API Changes

Documents that ExtVTable::validate_dtype must be independent of the storage dtype's top-level nullability. Validators can still constrain nullability inside nested storage types.

@connortsui20 connortsui20 added the changelog/break A breaking API change label Oct 29, 2026 — with ChatGPT Codex Connector
@codspeed

codspeed Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

2 warnings

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ 3 benchmarks with a significant change ran in a different software environment

Their base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the changes might come from this difference rather than from the code. Open an affected benchmark to see what changed.

See affected benchmarks

⚡ 4 improved benchmarks
❌ 1 regressed benchmark
✅ 2313 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation encode_primitives[u8, (2000, 4)] 135.5 µs 163.3 µs -17.06%
⚡ CPU Simulation filter_powerlaw_by_random[10000] 684 ns 539.5 ns +26.77%
⚡ CPU Simulation test_repeated_scan_filter[int] 2.4 ms 2.1 ms +12.9%
⚡ CPU Simulation test_scan_filter_to_arrow_array[int] 2.8 ms 2.5 ms +10.95%
⚡ CPU Simulation test_scan_filter[int] 2.9 ms 2.6 ms +10.51%

Tip

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


Comparing ct/ext-types/dtype-invariants (bf78865) with develop (96fc43d)

Open in CodSpeed

@connortsui20
connortsui20 marked this pull request as draft October 30, 2026 00:13
@connortsui20
connortsui20 force-pushed the ct/ext-types/dtype-invariants branch 2 times, most recently from 963b7ec to 35c68ec Compare October 30, 2026 13:46
@connortsui20

Copy link
Copy Markdown
Member Author

So this is definitely wrong, and it seems like we need to do a bit more design work around storage dtypes and nullability

@connortsui20
connortsui20 deleted the ct/ext-types/dtype-invariants branch October 30, 2026 14:02
An extension type cannot restrict whether its values can be null, so
`ExtVTable::validate_dtype` must not depend on the top-level nullability
of the storage dtype. `ExtDType::with_nullability` now relies on that
contract and rebuilds the dtype without validating again, so nullability
changes in `take`, `mask` and `min_max` cannot panic.

Also fixes `Debug for ExtDTypeRef`, which printed the metadata before the
struct and then `metadata: Ok(())`.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
@connortsui20
connortsui20 restored the ct/ext-types/dtype-invariants branch October 30, 2026 19:33
@connortsui20 connortsui20 reopened this Oct 30, 2026
@connortsui20 connortsui20 changed the title Validate extension dtype nullability and fix debug output Change extension dtype nullability without validating again Oct 30, 2026
@connortsui20
connortsui20 force-pushed the ct/ext-types/dtype-invariants branch from 35c68ec to f2c669e Compare October 30, 2026 19:34
@connortsui20
connortsui20 marked this pull request as ready for review October 30, 2026 21:10
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>

This branch has not been deployed

No deployments
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.

1 participant