Draft
Conversation
## Summary Adds `Operator::SafeDiv` — a division variant where a non-null zero divisor yields 0 rather than erroring. Integer overflow still errors (`i32::MIN / -1`), matching `Div`. Null on either side propagates. ## Implementation The array-level kernel is a hand-written single-pass `match_each_native_ptype!` loop (not a composition of existing ops). It runs over primitive slices once, combining validity from both inputs and producing a `PrimitiveArray` directly. Wiring touches the usual places a new binary arithmetic operator hits: proto enum and generated bindings, `Operator` / `NumericOperator` with their conversions, the `Binary` scalar-fn dispatcher (including stat_falsification), scalar-level `checked_binary_numeric` for both primitive and decimal scalars, and the FFI C enum. To combine validity from the two input arrays, the kernel calls `Validity::and` and then eagerly materializes the resulting lazy `Binary(And)` expression via `execute::<BoolArray>(ctx)`. This required threading `ExecutionCtx` through `execute_numeric` from the `Binary` dispatcher. Scope note: array-level SafeDiv is primitive-only. A decimal-array input fails with a clear error rather than silently inheriting the zero-rhs-errs behavior from arrow-arith; scalar-level decimal SafeDiv (used by the constant-constant fast path) is supported. ## Testing - 5 primitive scalar tests (integer, integer-by-zero, overflow still errs, float-by-zero yields 0.0 not Inf, null propagation) - 1 decimal scalar test (by-zero yields zero, not None) - 4 array-level tests (integer-by-zero, float-by-zero, nullable propagation from both sides, constant-zero rhs fast path) - Conformance harness: SafeDiv added to the operator arrays and is exercised with zero-valued scalars (unlike Div, which is skipped) - `cargo test -p vortex-array --lib` → 2556 passed, 0 failed - `cargo clippy -p vortex-array -p vortex-ffi -p vortex-proto --all-targets --all-features` → clean - `cargo fmt --all` → clean (nightly fmt unavailable in this sandbox) Signed-off-by: Claude <noreply@anthropic.com> https://claude.ai/code/session_01MLXfBVfMbrUgRPafnt5GHC Signed-off-by: Claude <noreply@anthropic.com>
Merging this PR will improve performance by 29.38%
Performance Changes
Comparing Footnotes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
Operator::SafeDiv— a division variant where a non-null zerodivisor yields 0 rather than erroring. Integer overflow still errors
(
i32::MIN / -1), matchingDiv. Null on either side propagates.Implementation
The array-level kernel is a hand-written single-pass
match_each_native_ptype!loop (not a composition of existing ops). Itruns over primitive slices once, combining validity from both inputs
and producing a
PrimitiveArraydirectly.Wiring touches the usual places a new binary arithmetic operator hits:
proto enum and generated bindings,
Operator/NumericOperatorwiththeir conversions, the
Binaryscalar-fn dispatcher (includingstat_falsification), scalar-level
checked_binary_numericfor bothprimitive and decimal scalars, and the FFI C enum.
To combine validity from the two input arrays, the kernel calls
Validity::andand then eagerly materializes the resulting lazyBinary(And)expression viaexecute::<BoolArray>(ctx). This requiredthreading
ExecutionCtxthroughexecute_numericfrom theBinarydispatcher.
Scope note: array-level SafeDiv is primitive-only. A decimal-array
input fails with a clear error rather than silently inheriting the
zero-rhs-errs behavior from arrow-arith; scalar-level decimal SafeDiv
(used by the constant-constant fast path) is supported.
Testing
errs, float-by-zero yields 0.0 not Inf, null propagation)
propagation from both sides, constant-zero rhs fast path)
exercised with zero-valued scalars (unlike Div, which is skipped)
cargo test -p vortex-array --lib→ 2556 passed, 0 failedcargo clippy -p vortex-array -p vortex-ffi -p vortex-proto --all-targets --all-features→ cleancargo fmt --all→ clean (nightly fmt unavailable in this sandbox)Signed-off-by: Claude noreply@anthropic.com
https://claude.ai/code/session_01MLXfBVfMbrUgRPafnt5GHC
Signed-off-by: Claude noreply@anthropic.com