diff --git a/src/substrait.rs b/src/substrait.rs index 7d57a660..1e9e16c7 100644 --- a/src/substrait.rs +++ b/src/substrait.rs @@ -40,7 +40,7 @@ impl PyPlan { self.plan .encode(&mut proto_bytes) .map_err(DataFusionError::EncodeError)?; - Ok(PyBytes::new(py, &proto_bytes).into()) + Ok(PyBytes::new_bound(py, &proto_bytes).unbind().into()) } } @@ -76,7 +76,7 @@ impl PySubstraitSerializer { pub fn serialize_to_plan(sql: &str, ctx: PySessionContext, py: Python) -> PyResult { match PySubstraitSerializer::serialize_bytes(sql, ctx, py) { Ok(proto_bytes) => { - let proto_bytes: &PyBytes = proto_bytes.as_ref(py).downcast().unwrap(); + let proto_bytes = proto_bytes.bind(py).downcast::().unwrap(); PySubstraitSerializer::deserialize_bytes(proto_bytes.as_bytes().to_vec(), py) } Err(e) => Err(py_datafusion_err(e)), @@ -87,7 +87,7 @@ impl PySubstraitSerializer { pub fn serialize_bytes(sql: &str, ctx: PySessionContext, py: Python) -> PyResult { let proto_bytes: Vec = wait_for_future(py, serializer::serialize_bytes(sql, &ctx.ctx)) .map_err(DataFusionError::from)?; - Ok(PyBytes::new(py, &proto_bytes).into()) + Ok(PyBytes::new_bound(py, &proto_bytes).unbind().into()) } #[staticmethod]