Skip to content

Commit 21906bb

Browse files
committed
Fix pyarrow calls and improve type handling in RustAccumulator
1 parent fbba2a0 commit 21906bb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/udaf.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl Accumulator for RustAccumulator {
7373
kwargs.set_item("type", py_type)?;
7474
return pyarrow
7575
.getattr("scalar")?
76-
.call((list_value,), Some(kwargs))?
76+
.call((list_value,), Some(&kwargs))?
7777
.extract::<PyScalarValue>();
7878
}
7979
value.extract::<PyScalarValue>()
@@ -166,15 +166,17 @@ pub fn to_rust_accumulator(accum: Py<PyAny>) -> AccumulatorFactoryFunction {
166166
})?;
167167
Ok(Box::new(RustAccumulator::new(
168168
accum,
169-
args.return_type.clone(),
169+
args.return_type().clone(),
170170
)))
171171
})
172172
}
173173

174174
fn is_pyarrow_array_like(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<bool> {
175175
let pyarrow = PyModule::import(py, "pyarrow")?;
176-
let array_type = pyarrow.getattr("Array")?.downcast::<PyType>()?;
177-
let chunked_array_type = pyarrow.getattr("ChunkedArray")?.downcast::<PyType>()?;
176+
let array_attr = pyarrow.getattr("Array")?;
177+
let array_type = array_attr.downcast::<PyType>()?;
178+
let chunked_array_attr = pyarrow.getattr("ChunkedArray")?;
179+
let chunked_array_type = chunked_array_attr.downcast::<PyType>()?;
178180
Ok(value.is_instance(array_type)? || value.is_instance(chunked_array_type)?)
179181
}
180182

0 commit comments

Comments
 (0)