diff --git a/Cargo.toml b/Cargo.toml index 18a0716..75c022e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,8 +8,8 @@ members = [ ] [workspace.dependencies] -polars = { version = "0.39.0", default-features = false } -polars-core = { version = "0.39.0", default-features = false } -polars-ffi = { version = "0.39.0", default-features = false } -polars-plan = { version = "0.39.0", default-feautres = false } -polars-lazy = { version = "0.39.0", default-features = false } +polars = { version = "0.40.0", default-features = false } +polars-core = { version = "0.40.0", default-features = false } +polars-ffi = { version = "0.40.0", default-features = false } +polars-plan = { version = "0.40.0", default-feautres = false } +polars-lazy = { version = "0.40.0", default-features = false } diff --git a/pyo3-polars-derive/Cargo.toml b/pyo3-polars-derive/Cargo.toml index 1e415d7..10aa318 100644 --- a/pyo3-polars-derive/Cargo.toml +++ b/pyo3-polars-derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyo3-polars-derive" -version = "0.7.0" +version = "0.8.0" edition = "2021" license = "MIT" readme = "README.md" diff --git a/pyo3-polars/Cargo.toml b/pyo3-polars/Cargo.toml index ec879fe..3c1fda2 100644 --- a/pyo3-polars/Cargo.toml +++ b/pyo3-polars/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyo3-polars" -version = "0.13.0" +version = "0.14.0" edition = "2021" license = "MIT" readme = "../README.md" @@ -17,7 +17,7 @@ polars-ffi = { workspace = true, optional = true } polars-lazy = { workspace = true, optional = true } polars-plan = { workspace = true, optional = true } pyo3 = "0.21.0" -pyo3-polars-derive = { version = "0.7.0", path = "../pyo3-polars-derive", optional = true } +pyo3-polars-derive = { version = "0.8.0", path = "../pyo3-polars-derive", optional = true } serde = { version = "1", optional = true } serde-pickle = { version = "1", optional = true } thiserror = "1" diff --git a/pyo3-polars/src/error.rs b/pyo3-polars/src/error.rs index 9e38cf6..d93b22d 100644 --- a/pyo3-polars/src/error.rs +++ b/pyo3-polars/src/error.rs @@ -16,16 +16,13 @@ pub enum PyPolarsErr { impl std::convert::From for PyErr { fn from(err: PyPolarsErr) -> PyErr { - let default = || PyRuntimeError::new_err(format!("{:?}", &err)); - - use PyPolarsErr::*; - match &err { - Polars(err) => match err { + fn convert(err: &PolarsError) -> PyErr { + match err { PolarsError::ComputeError(err) => ComputeError::new_err(err.to_string()), PolarsError::NoData(err) => NoDataError::new_err(err.to_string()), PolarsError::ShapeMismatch(err) => ShapeError::new_err(err.to_string()), PolarsError::SchemaMismatch(err) => SchemaError::new_err(err.to_string()), - PolarsError::Io(err) => PyIOError::new_err(err.to_string()), + PolarsError::IO { error, .. } => PyIOError::new_err(error.to_string()), PolarsError::OutOfBounds(err) => PyIndexError::new_err(err.to_string()), PolarsError::InvalidOperation(err) => PyValueError::new_err(err.to_string()), PolarsError::Duplicate(err) => DuplicateError::new_err(err.to_string()), @@ -39,8 +36,14 @@ impl std::convert::From for PyErr { PolarsError::StringCacheMismatch(err) => { StringCacheMismatchError::new_err(err.to_string()) } - }, - _ => default(), + PolarsError::Context { error, .. } => convert(error), + } + } + + use PyPolarsErr::*; + match &err { + Polars(err) => convert(err), + _ => PyRuntimeError::new_err(format!("{:?}", &err)), } } } diff --git a/pyo3-polars/src/lib.rs b/pyo3-polars/src/lib.rs index 08aa0c5..a0427b9 100644 --- a/pyo3-polars/src/lib.rs +++ b/pyo3-polars/src/lib.rs @@ -56,7 +56,7 @@ use pyo3::ffi::Py_uintptr_t; use pyo3::prelude::*; #[cfg(feature = "lazy")] -use {polars_lazy::frame::LazyFrame, polars_plan::logical_plan::LogicalPlan}; +use {polars_lazy::frame::LazyFrame, polars_plan::logical_plan::DslPlan}; #[repr(transparent)] #[derive(Debug, Clone)] @@ -152,7 +152,7 @@ impl<'a> FromPyObject<'a> for PyDataFrame { impl<'a> FromPyObject<'a> for PyLazyFrame { fn extract_bound(ob: &Bound<'a, PyAny>) -> PyResult { let s = ob.call_method0("__getstate__")?.extract::>()?; - let lp: LogicalPlan = ciborium::de::from_reader(&*s).map_err( + let lp: DslPlan = ciborium::de::from_reader(&*s).map_err( |e| PyPolarsErr::Other( format!("Error when deserializing LazyFrame. This may be due to mismatched polars versions. {}", e) )