Skip to content

fix(rust,python): Schema inconsistent on Decimal arithmetic with integer - #28819

Open
BhargavKumarNath wants to merge 5 commits into
pola-rs:mainfrom
BhargavKumarNath:fix-decimal-schema-28654
Open

fix(rust,python): Schema inconsistent on Decimal arithmetic with integer#28819
BhargavKumarNath wants to merge 5 commits into
pola-rs:mainfrom
BhargavKumarNath:fix-decimal-schema-28654

Conversation

@BhargavKumarNath

Copy link
Copy Markdown

Fixes a schema inconsistency where operations between a Decimal and an integer would preserve the original decimal precision during lazy schema inference (e.g. Decimal(10, 2)), while the actual physical runtime correctly operates using maximum precision Decimal(38, 2) (DEC128_MAX_PREC).

This PR updates schema.rs to explicitly handle Decimal op integer across +, -, *, and /, ensuring get_arithmetic_field and get_truediv_field correctly return Decimal(DEC128_MAX_PREC, scale) to match the eager runtime schema.

Tests Added a parametric test suite in test_arithmetic.py that verifies collect_schema() matches collect().schema for Decimal interactions against all 9 integer types (Int8 through Int128, UInt8 through UInt64) and basic operators.

I used AI to design the test suites.
I confirm that I have reviewed all changes myself, and I believe they are relevant and correct.

pr

@github-actions github-actions Bot added A-dtype-decimal Area: decimal data type fix Bug fix python Related to Python Polars rust Related to Rust Polars first-contribution First contribution by user title needs formatting labels Aug 14, 2026
@BhargavKumarNath
BhargavKumarNath force-pushed the fix-decimal-schema-28654 branch from ccbfdde to c2e2650 Compare August 14, 2026 14:06
@BhargavKumarNath BhargavKumarNath changed the title fix(rust, python): Schema inconsistent on Decimal arithmetic with integer (#28654) fix(rust,python): Schema inconsistent on Decimal arithmetic with integer Aug 14, 2026
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.56%. Comparing base (4f632e0) to head (0dfcd05).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #28819      +/-   ##
==========================================
+ Coverage   81.51%   81.56%   +0.04%     
==========================================
  Files        1888     1888              
  Lines      266924   267749     +825     
  Branches     3240     3240              
==========================================
+ Hits       217594   218399     +805     
- Misses      48502    48522      +20     
  Partials      828      828              

☔ View full report in Codecov by Harness.
📢 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.

@BhargavKumarNath

Copy link
Copy Markdown
Author

Fix complete. All checks passed

@BhargavKumarNath
BhargavKumarNath force-pushed the fix-decimal-schema-28654 branch from 50174e2 to c297a09 Compare August 18, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-dtype-decimal Area: decimal data type first-contribution First contribution by user fix Bug fix python Related to Python Polars rust Related to Rust Polars

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant