Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bindings/python/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

---

# Changes in Version 1.11.1 (2025/12/15)

- Add support for Polars 1.36.0.

# Changes in Version 1.11.0 (2025/12/10)

- Add support for PyArrow 22.0.
Expand Down
18 changes: 11 additions & 7 deletions bindings/python/test/test_polars.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,19 @@ def test_polars_types(self):
df_out = find_polars_all(self.coll, {}, schema=Schema(pa_schema))
pl.testing.assert_frame_equal(df_in, df_out)

def test_extension_types_fail(self):
"""Confirm failure on ExtensionTypes for Polars.DataFrame.from_arrow"""

def test_extension_types(self):
"""Confirm ExtensionTypes for Polars.DataFrame.from_arrow"""
if not hasattr(pl, "register_extension_type"):
raise unittest.SkipTest("Requires polars extension types")
for ext_type, data in (
(ObjectIdType(), [bson.ObjectId().binary, bson.ObjectId().binary]),
(Decimal128Type(), [bson.Decimal128(str(i)).bid for i in range(2)]),
(CodeType(), [str(i) for i in range(2)]),
):
table = pa.Table.from_pydict({"foo": data}, pa.schema({"foo": ext_type}))
with self.assertRaises(pl.exceptions.ComputeError):
pl.from_arrow(table)
df = pl.from_arrow(table)
expected = pl.datatypes.String if ext_type == CodeType() else pl.datatypes.Binary
assert df.dtypes[0] == expected, ext_type

def test_auto_schema_succeeds_on_find(self):
"""Confirms Polars can read ObjectID Extension type.
Expand Down Expand Up @@ -331,6 +333,8 @@ def test_bson_types(self):
Note that this tests only types currently supported by Arrow.
bson.Regex is not included, for example.
"""
if not hasattr(pl, "register_extension_type"):
raise unittest.SkipTest("Requires polars extension types")

# 1. Use pymongo / bson packages to build create and write tabular data
self.coll.drop()
Expand Down Expand Up @@ -376,7 +380,7 @@ def test_bson_types(self):
"type": "object id",
"value": bson.ObjectId(),
"atype": ObjectIdType(),
"ptype": pl.Object,
"ptype": pl.Binary,
},
{
"type": "javascript",
Expand All @@ -388,7 +392,7 @@ def test_bson_types(self):
"type": "decimal128",
"value": bson.Decimal128("10.99"),
"atype": Decimal128Type(),
"ptype": pl.Decimal,
"ptype": pl.Binary,
},
{
"type": "uuid",
Expand Down
Loading
Loading