[ABA-28] test(vortex-array): repro for DecimalValue PartialOrd/PartialEq ignoring scale#19
Open
abnobdoss wants to merge 1 commit into
Open
[ABA-28] test(vortex-array): repro for DecimalValue PartialOrd/PartialEq ignoring scale#19abnobdoss wants to merge 1 commit into
abnobdoss wants to merge 1 commit into
Conversation
…lEq ignore scale Add two #[ignore]'d tests in dvalue.rs::tests that demonstrate the raw-API bug where DecimalValue::PartialEq and ::PartialOrd compare the raw i256 coefficient with no scale awareness (lines 176-189 and 193-206). Both tests are left ignored pending a design decision on the raw-API contract for cross-scale comparison. See: https://linear.app/abanoubdoss/issue/ABA-28 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Abanoub Doss <abanoub.doss@gmail.com>
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
#[ignore]'d regression tests inline invortex-array/src/scalar/typed_view/decimal/dvalue.rsthat reproduce the ABA-28 raw-API bug.DecimalValue::I32(10)at scale 1 (=1.0) vsDecimalValue::I32(10)at scale 2 (=0.10) —PartialEqreturnstruebecausedvalue.rs:176-189only compares the raw i256 coefficient; numerically 1.0 != 0.10.DecimalValue::I32(10)at scale 1 (=1.0) vsDecimalValue::I32(50)at scale 2 (=0.5) —partial_cmpreturnsSome(Less)because raw 10 < 50; numerically 1.0 > 0.5.Linear: https://linear.app/abanoubdoss/issue/ABA-28
Repro-only PR — no fix yet. Both tests are left
#[ignore]'d pending a design call (see open question below).Verification
Tests fail correctly when un-ignored:
Open question — raw API contract for cross-scale compare
DecimalValuecarries no scale; the comment atdvalue.rs:172-175explicitly delegates scale enforcement toDecimalScalar. Three options for the fix:(a) Canonicalize then compare — require callers to pass scale alongside each operand (e.g. a new
DecimalValue::cmp_with_scalemethod) and normalize to a common scale before comparing. Clean semantics; breaks the currentPartialOrd/PartialEqsignature contract.(b) Refuse to derive
PartialOrd/PartialEqacross scales — remove or gate the impls so the compiler prevents misuse. Safest contract; requires updating every call site that today relies on same-scale equality.(c) Document as same-scale-only +
debug_assert— keep the current impls as a same-scale-only fast path, add// # Panics (debug)doc section and adebug_assertthat fires when scales mismatch in debug builds. Zero runtime cost in release; only catches misuse in test/dev runs.The higher-layer gate at
binary/mod.rs:121already enforces same-scale before any array compare reaches the raw value, so option (c) may be sufficient.Generated with Claude Code