Skip to content

Validate extension storage and return scalar read errors - #11014

Merged
connortsui20 merged 6 commits into
developfrom
ct/ext-types/scalar-validation
Nov 2, 2026
Merged

connortsui20 merged 6 commits into
developfrom
ct/ext-types/scalar-validation

Conversation

@connortsui20

@connortsui20 connortsui20 commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Extension validators assume that values already match their storage dtype, but scalar construction did not check that assumption. A wrong value representation could reach a validator and panic. Extension arrays also defer value validation until a scalar is read, so row reads and aggregate results need to return validation errors to the caller.

Changes

Validates the storage representation before calling the extension validator and uses fallible construction for reads, constant folding, and aggregate results. Constant folding declines invalid values so raw storage access and slicing still work. Legacy F16 bits are normalized at construction to keep the in-memory representation consistent.

Regression tests cover these boundaries, including cached NaN statistics and rejected zero values. Checks for the style cleanup are left to CI.

API Changes

Adds Scalar::try_extension_ref for callers that need to handle invalid storage. Scalar::zero_value keeps its documented panic when the dtype has no valid non-null zero.

@codspeed

codspeed Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 15.32%

1 warning

⚠️ 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

⚡ 2 improved benchmarks
❌ 5 regressed benchmarks
✅ 2311 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Walltime filter_neon[64] 1.9 µs 2.9 µs -34.05%
❌ CPU Simulation filter_powerlaw_by_random[10000] 1.4 µs 2 µs -30.25%
❌ Walltime threshold_neon[64] 2.6 µs 3.4 µs -23.66%
❌ Walltime threshold_neon[80] 3.3 µs 4.2 µs -20.61%
❌ Walltime filter_neon[80] 2.7 µs 3.4 µs -19.87%
⚡ CPU Simulation encode_primitives[u8, (2000, 4)] 162.5 µs 134.4 µs +20.96%
⚡ CPU Simulation take_filter_primitive_small_uncached_random_mask_random_indices[4096, 10] 24.8 µs 21.5 µs +15.56%

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/scalar-validation (a0e2368) with develop (3f12ae4)

Open in CodSpeed

@connortsui20
connortsui20 marked this pull request as draft October 29, 2026 22:22
@connortsui20
connortsui20 force-pushed the ct/ext-types/scalar-validation branch 2 times, most recently from 482b0ba to cb940e8 Compare October 30, 2026 13:46
connortsui20 added a commit to gitRasheed/vortex that referenced this pull request Oct 30, 2026
@connortsui20

Copy link
Copy Markdown
Member Author

Pretty sure the microbenchmarks arent real

@connortsui20
connortsui20 marked this pull request as ready for review October 30, 2026 21:10
Comment on lines +260 to +267
/// Creates an extension scalar after checking its storage dtype and value.
///
/// # Errors
///
/// Returns an error if the storage dtype differs from the extension's storage dtype, or if
/// the extension rejects the storage value. A null storage scalar requires a nullable dtype.
pub fn try_extension_ref(ext_dtype: ExtDTypeRef, storage_scalar: Scalar) -> VortexResult<Self> {
vortex_ensure_eq!(ext_dtype.storage_dtype(), storage_scalar.dtype());

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.

this is the main change

Comment thread vortex-array/src/scalar/validate.rs Resolved
Move legacy F16 normalization behind the compatibility check so canonical
values avoid the conversion branch.

Signed-off-by: Connor Tsui <[email protected]>
@connortsui20
connortsui20 force-pushed the ct/ext-types/scalar-validation branch from cd5acd2 to 8b472f2 Compare November 2, 2026 13:53
@connortsui20
connortsui20 force-pushed the ct/ext-types/scalar-validation branch from 9db78cb to 20036cf Compare November 2, 2026 14:13
Signed-off-by: Connor Tsui <[email protected]>
@connortsui20
connortsui20 enabled auto-merge (squash) November 2, 2026 16:28
@connortsui20
connortsui20 merged commit 38dc319 into develop Nov 2, 2026
83 of 92 checks passed
@connortsui20
connortsui20 deleted the ct/ext-types/scalar-validation branch November 2, 2026 16:38
@connortsui20 connortsui20 mentioned this pull request Nov 2, 2026
9 tasks done
connortsui20 added a commit that referenced this pull request Nov 2, 2026
U2, U3, U4, U6, U7 and U8 merged on 2026-11-02 in #11012, #11014 and
#11016, and the DataFusion literal fix #11067 merged right after U2. So
order constraint 1 holds, and phase 1 starts from develop. The graph
shows these nodes as merged, and parts 2 and 4 name the PR that fixed
each finding.

#10953 now keeps i32 days and widens only the days part to i64 when a
value does not fit. It has no review, and it conflicts with the
DateTimeParts compare kernel that U2 changed. #11056 still waits on its
request for changes. #10661 replaces the closed #10482 for file sort
statistics.

In the type roadmap, only the N1 sentence changes.

Signed-off-by: Connor Tsui <[email protected]>
@connortsui20 connortsui20 mentioned this pull request Nov 2, 2026
12 of 49 tasks
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.

2 participants