Skip to content

[ABA-28] test(vortex-array): repro for DecimalValue PartialOrd/PartialEq ignoring scale#19

Open
abnobdoss wants to merge 1 commit into
developfrom
fix/aba-28-decimal-value-partial-ord-scale
Open

[ABA-28] test(vortex-array): repro for DecimalValue PartialOrd/PartialEq ignoring scale#19
abnobdoss wants to merge 1 commit into
developfrom
fix/aba-28-decimal-value-partial-ord-scale

Conversation

@abnobdoss
Copy link
Copy Markdown
Owner

Summary

  • Adds two #[ignore]'d regression tests inline in vortex-array/src/scalar/typed_view/decimal/dvalue.rs that reproduce the ABA-28 raw-API bug.
  • PartialEq probe: DecimalValue::I32(10) at scale 1 (=1.0) vs DecimalValue::I32(10) at scale 2 (=0.10) — PartialEq returns true because dvalue.rs:176-189 only compares the raw i256 coefficient; numerically 1.0 != 0.10.
  • PartialOrd probe: DecimalValue::I32(10) at scale 1 (=1.0) vs DecimalValue::I32(50) at scale 2 (=0.5) — partial_cmp returns Some(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:

test ...partial_eq_ignores_scale_at_raw_api ... FAILED
  assertion `left != right` failed: ... PartialEq returned true ...
  left: I32(10)  right: I32(10)

test ...partial_ord_ignores_scale_at_raw_api ... FAILED
  assertion `left == right` failed: ... PartialOrd returned Less ...
  left: Some(Less)  right: Some(Greater)

Open question — raw API contract for cross-scale compare

DecimalValue carries no scale; the comment at dvalue.rs:172-175 explicitly delegates scale enforcement to DecimalScalar. Three options for the fix:

(a) Canonicalize then compare — require callers to pass scale alongside each operand (e.g. a new DecimalValue::cmp_with_scale method) and normalize to a common scale before comparing. Clean semantics; breaks the current PartialOrd/PartialEq signature contract.

(b) Refuse to derive PartialOrd/PartialEq across 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 a debug_assert that 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:121 already enforces same-scale before any array compare reaches the raw value, so option (c) may be sufficient.


Generated with Claude Code

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant