Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit bf6e84d

Browse files
committed
Fix serialization
1 parent db2b6c9 commit bf6e84d

5 files changed

Lines changed: 21 additions & 24 deletions

File tree

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ polars-arrow = { version = "0.48.0", default-features = false }
1515
polars-ffi = { version = "0.48.0", default-features = false }
1616
polars-plan = { version = "0.48.0", default-features = false }
1717
polars-lazy = { version = "0.48.0", default-features = false }
18-
polars-python = {version = "0.48.0", default-features = false }
19-
polars-utils = {version = "0.48.0", default-features = false}
18+
polars-python = { version = "0.48.0", default-features = false }
19+
polars-utils = { version = "0.48.0", default-features = false }
2020

2121
[workspace.dependencies.arrow]
2222
package = "polars-arrow"
2323
version = "0.48.0"
2424
path = "../polars/crates/polars-arrow"
2525
default-features = false
2626

27-
#[patch.crates-io]
28-
#polars = { git = "https://github.com/pola-rs/polars.git" }
29-
#polars-core = { git = "https://github.com/pola-rs/polars.git" }
30-
#polars-ffi = { git = "https://github.com/pola-rs/polars.git" }
31-
#polars-plan = { git = "https://github.com/pola-rs/polars.git" }
32-
#polars-lazy = { git = "https://github.com/pola-rs/polars.git" }
27+
# [patch.crates-io]
28+
# polars = { git = "https://github.com/pola-rs/polars.git" }
29+
# polars-core = { git = "https://github.com/pola-rs/polars.git" }
30+
# polars-ffi = { git = "https://github.com/pola-rs/polars.git" }
31+
# polars-plan = { git = "https://github.com/pola-rs/polars.git" }
32+
# polars-lazy = { git = "https://github.com/pola-rs/polars.git" }

example/derive_expression/expression_lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ name = "expression_lib"
99
crate-type = ["cdylib"]
1010

1111
[dependencies]
12+
num = "*"
1213
polars = { workspace = true, features = ["fmt", "dtype-date", "timezones"], default-features = false }
1314
polars-arrow = { workspace = true, default-features = false }
1415
pyo3 = { version = "0.24.2", features = ["abi3-py38"] }
1516
pyo3-polars = { version = "*", path = "../../../pyo3-polars", features = ["derive"] }
1617
rayon = "1.7.0"
1718
serde = { version = "1", features = ["derive"] }
18-
num = "*"

pyo3-polars-derive/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ name = "tests"
1717
path = "tests/run.rs"
1818

1919
[dependencies]
20+
polars-arrow = { workspace = true }
2021
polars-core = { workspace = true }
2122
polars-ffi = { workspace = true }
2223
polars-plan = { workspace = true }
23-
polars-arrow = { workspace = true }
2424
proc-macro2 = "1.0"
2525
quote = "1.0"
2626
syn = { version = "2", features = ["full", "extra-traits"] }
2727

2828
[dev-dependencies]
29+
pyo3-polars = { version = "0.21.0", path = "../pyo3-polars", features = ["derive"] }
2930
trybuild = { version = "1", features = ["diff"] }
30-
pyo3-polars = { version = "0.21.0", path = "../pyo3-polars", features = ["derive"] }

pyo3-polars/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ description = "Expression plugins and PyO3 types for polars"
1212
[dependencies]
1313
libc = "0.2" # pyo3 depends on libc already, so this does not introduce an extra dependence.
1414
once_cell = "1"
15-
polars = { workspace = true, default-features = true}
15+
polars = { workspace = true, default-features = true }
1616
polars-arrow = { workspace = true, default-features = false }
1717
polars-core = { workspace = true, default-features = false }
1818
polars-ffi = { workspace = true, optional = true }
1919
polars-lazy = { workspace = true, optional = true }
2020
polars-plan = { workspace = true, optional = true }
21-
polars-utils = {workspace = true, features = ["serde"], optional = true }
21+
polars-utils = { workspace = true, features = ["serde"], optional = true }
2222
pyo3 = "0.24.2"
2323
pyo3-polars-derive = { version = "0.15.0", path = "../pyo3-polars-derive", optional = true }
2424
serde = { version = "1", optional = true }

pyo3-polars/src/types.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,11 @@ impl<'a> FromPyObject<'a> for PyLazyFrame {
220220
let b = s.extract::<Bound<'_, PyBytes>>()?;
221221
let b = b.as_bytes();
222222

223-
let lp: DslPlan = pl_serialize::SerializeOptions::default()
224-
.deserialize_from_reader::<DslPlan, &[u8], false>(&*b)
225-
.map_err(
223+
let lp = DslPlan::deserialize_versioned(b).map_err(
226224
|e| PyPolarsErr::Other(
227-
format!("Error when deserializing LazyFrame. This may be due to mismatched polars versions. {}", e)
228-
)
229-
)?;
225+
format!("Error when deserializing LazyFrame. This may be due to mismatched polars versions. {e}")
226+
))
227+
?;
230228

231229
Ok(PyLazyFrame(LazyFrame::from(lp)))
232230
}
@@ -241,7 +239,7 @@ impl<'a> FromPyObject<'a> for PyExpr {
241239
.deserialize_from_reader::<Expr, &[u8], false>(&*s)
242240
.map_err(
243241
|e| PyPolarsErr::Other(
244-
format!("Error when deserializing 'Expr'. This may be due to mismatched polars versions. {}", e)
242+
format!("Error when deserializing 'Expr'. This may be due to mismatched polars versions. {e}")
245243
)
246244
)?;
247245

@@ -358,10 +356,9 @@ impl<'py> IntoPyObject<'py> for PyLazyFrame {
358356
let cls = polars.getattr("LazyFrame")?;
359357
let instance = cls.call_method1(intern!(py, "__new__"), (&cls,)).unwrap();
360358

361-
let buf = pl_serialize::SerializeOptions::default()
362-
.serialize_to_bytes::<DslPlan, false>(&self.0.logical_plan)
363-
.unwrap();
364-
instance.call_method1("__setstate__", (&buf,))?;
359+
let mut v = vec![];
360+
self.0.logical_plan.serialize_versioned(&mut v).unwrap();
361+
instance.call_method1("__setstate__", (&v,))?;
365362
Ok(instance)
366363
}
367364
}

0 commit comments

Comments
 (0)