Skip to content

Commit

Permalink
pyo3-polars 0.14.0; rust polars 0.40.0 (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored May 21, 2024
1 parent 2978297 commit 2080d3d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
2 changes: 1 addition & 1 deletion pyo3-polars-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyo3-polars-derive"
version = "0.7.0"
version = "0.8.0"
edition = "2021"
license = "MIT"
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions pyo3-polars/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyo3-polars"
version = "0.13.0"
version = "0.14.0"
edition = "2021"
license = "MIT"
readme = "../README.md"
Expand All @@ -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"
Expand Down
19 changes: 11 additions & 8 deletions pyo3-polars/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@ pub enum PyPolarsErr {

impl std::convert::From<PyPolarsErr> 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()),
Expand All @@ -39,8 +36,14 @@ impl std::convert::From<PyPolarsErr> 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)),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pyo3-polars/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -152,7 +152,7 @@ impl<'a> FromPyObject<'a> for PyDataFrame {
impl<'a> FromPyObject<'a> for PyLazyFrame {
fn extract_bound(ob: &Bound<'a, PyAny>) -> PyResult<Self> {
let s = ob.call_method0("__getstate__")?.extract::<Vec<u8>>()?;
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)
)
Expand Down

0 comments on commit 2080d3d

Please sign in to comment.