Skip to content

feat: Add support for unsigned 128-bit integers#24346

Merged
ritchie46 merged 30 commits into
pola-rs:mainfrom
dsprenkels:u128
Sep 17, 2025
Merged

feat: Add support for unsigned 128-bit integers#24346
ritchie46 merged 30 commits into
pola-rs:mainfrom
dsprenkels:u128

Conversation

@dsprenkels
Copy link
Copy Markdown
Collaborator

@dsprenkels dsprenkels commented Sep 3, 2025

This PR is still a draft. I'll undraft it after double-checking some things tomorrow.

This PR is ready

@dsprenkels dsprenkels changed the title Add support for unsigned 128-bit integers feat: Add support for unsigned 128-bit integers Sep 3, 2025
@github-actions github-actions Bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars and removed title needs formatting labels Sep 3, 2025
@dsprenkels dsprenkels added do not merge This pull requests should not be merged right now A-dtype Area: data types in general merge-after-dsl-unfreeze labels Sep 3, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 4, 2025

Codecov Report

❌ Patch coverage is 72.61905% with 69 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.78%. Comparing base (e2d9e26) to head (62b40d5).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
crates/polars-compute/src/float_sum.rs 0.00% 9 Missing ⚠️
crates/polars-core/src/datatypes/any_value.rs 50.00% 9 Missing ⚠️
crates/polars-python/src/series/map.rs 0.00% 7 Missing ⚠️
...tes/polars-ops/src/chunked_array/array/sum_mean.rs 0.00% 6 Missing ⚠️
crates/polars-compute/src/cast/mod.rs 82.75% 5 Missing ⚠️
crates/polars-arrow/src/array/proptest.rs 0.00% 3 Missing ⚠️
crates/polars-core/src/frame/column/mod.rs 50.00% 3 Missing ⚠️
crates/polars-ops/src/frame/join/asof/groups.rs 40.00% 3 Missing ⚠️
crates/polars-core/src/datatypes/dtype.rs 71.42% 2 Missing ⚠️
crates/polars-core/src/fmt.rs 0.00% 2 Missing ⚠️
... and 14 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24346      +/-   ##
==========================================
- Coverage   81.80%   81.78%   -0.02%     
==========================================
  Files        1684     1684              
  Lines      228518   228740     +222     
  Branches     2929     2929              
==========================================
+ Hits       186931   187075     +144     
- Misses      40850    40928      +78     
  Partials      737      737              

☔ 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.

// One side is signed, the other is unsigned. We just need to upcast the
// unsigned side to a signed integer with the next-largest bit width.
match (l, r) {
(UInt128, _) | (_, UInt128) => Some(Int128),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do things fail if this returns None? Because this function claims the cast must be lossless, which this isn't.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch. I updated this

assert_frame_equal(result, expected)


def test_from_dicts_schema_columns_do_not_match() -> None:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why was this test removed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not sure what happened here. I re-added the test

max_size=10,
excluded_dtypes=[
pl.Int128,
pl.UInt128,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why were both Int128 and UInt128 added to the excluded_dtypes? If i128 was already there I could maybe understand it but since it used to work before it should still work now, no?

Copy link
Copy Markdown
Collaborator Author

@dsprenkels dsprenkels Sep 8, 2025

Choose a reason for hiding this comment

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

I128 is not tested in parametric tests on main. In this PR I have added both U128 and I128 to the parametric testing types. However, I128 does not work for this test, because we serialize I128 to a custom _pli128 column (which is not supported by PyArrow).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Alright.

pl.UInt32,
pl.UInt64,
pl.Int128,
# TODO: pl.UInt128 literals are too large for Polars
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perhaps could you still test UInt128 and just add an exception for dtype.max() only for UInt128?

Copy link
Copy Markdown
Member

@orlp orlp left a comment

Choose a reason for hiding this comment

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

Some small questions, but other than that great work!

dsprenkels added a commit to dsprenkels/polars that referenced this pull request Sep 8, 2025
dsprenkels added a commit to dsprenkels/polars that referenced this pull request Sep 8, 2025
dsprenkels added a commit to dsprenkels/polars that referenced this pull request Sep 8, 2025
@ritchie46 ritchie46 merged commit 05a1da1 into pola-rs:main Sep 17, 2025
29 checks passed
@dsprenkels dsprenkels deleted the u128 branch September 23, 2025 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-dtype Area: data types in general do not merge This pull requests should not be merged right now enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants