Skip to content

Conversation

@AdamGS
Copy link
Contributor

@AdamGS AdamGS commented Oct 16, 2025

At this point I'm considering adding "Decimal expert" to my CV 😢

Signed-off-by: Adam Gutglick <adam@spiraldb.com>
@AdamGS AdamGS requested review from a10y and robert3005 October 16, 2025 15:19
@AdamGS AdamGS added the changelog/fix A bug fix label Oct 16, 2025
Copy link
Contributor

@robert3005 robert3005 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want a test as well

// Test with large i64 values that require i128 accumulation
let large_val = i64::MAX / 4;
let decimal = DecimalArray::new(
buffer![large_val, large_val, large_val, large_val],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you tweak this test to demonstrate that it would overflow the i64 range, but it still returns b/c it coerces up to i128? basically just change one of these to large_val + 1 or something?

Copy link
Contributor

@a10y a10y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, AFAICT both DuckDB and DataFusion don't attempt to catch overflow on SUM, they just let it wrap

@codecov
Copy link

codecov bot commented Oct 16, 2025

Codecov Report

❌ Patch coverage is 90.74074% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.24%. Comparing base (1ccff21) to head (a6f3f76).
⚠️ Report is 11 commits behind head on develop.

Files with missing lines Patch % Lines
vortex-array/src/arrays/decimal/compute/sum.rs 92.00% 12 Missing ⚠️
vortex-scalar/src/bigint/mod.rs 75.00% 3 Missing ⚠️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@robert3005
Copy link
Contributor

I think because we widen the return type you can let it wrap and if it wraps you would have a type error anyway

Signed-off-by: Robert Kruszewski <github@robertk.io>
@robert3005 robert3005 enabled auto-merge (squash) October 16, 2025 22:32
Signed-off-by: Robert Kruszewski <github@robertk.io>
Signed-off-by: Robert Kruszewski <github@robertk.io>
@robert3005 robert3005 merged commit 978a947 into develop Oct 17, 2025
39 checks passed
@robert3005 robert3005 deleted the adamg/fix-decimal-sum-overflow branch October 17, 2025 10:34
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.

Decimal sum can overflow

4 participants