Skip to content

Commit 9fb0349

Browse files
committed
Refactor from_pycapsule method to simplify capsule handling
1 parent ac5c16f commit 9fb0349

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/udaf.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,14 @@ impl PyAggregateUDF {
197197
pub fn from_pycapsule(func: Bound<'_, PyAny>) -> PyDataFusionResult<Self> {
198198
if func.is_instance_of::<PyCapsule>() {
199199
let capsule = func.downcast::<PyCapsule>().map_err(py_datafusion_err)?;
200-
let capsule: &Bound<'_, PyCapsule> = capsule.into();
201-
let function = aggregate_udf_from_capsule(capsule)?;
200+
let function = aggregate_udf_from_capsule(&capsule)?;
202201
return Ok(Self { function });
203202
}
204203

205204
if func.hasattr("__datafusion_aggregate_udf__")? {
206205
let capsule = func.getattr("__datafusion_aggregate_udf__")?.call0()?;
207206
let capsule = capsule.downcast::<PyCapsule>().map_err(py_datafusion_err)?;
208-
let capsule: &Bound<'_, PyCapsule> = capsule.into();
209-
let function = aggregate_udf_from_capsule(capsule)?;
207+
let function = aggregate_udf_from_capsule(&capsule)?;
210208
return Ok(Self { function });
211209
}
212210

0 commit comments

Comments
 (0)