Skip to content

Commit 25dfafc

Browse files
remove use of .unwrap() from pyarrow_function_to_rust
1 parent 7bab0a3 commit 25dfafc

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/udf.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ fn pyarrow_function_to_rust(
4040
// 1. cast args to Pyarrow arrays
4141
let py_args = args
4242
.iter()
43-
.map(|arg| arg.into_data().to_pyarrow(py).unwrap())
44-
.collect::<Vec<_>>();
43+
.map(|arg| {
44+
arg.into_data()
45+
.to_pyarrow(py)
46+
.map_err(|e| DataFusionError::Execution(format!("{e:?}")))
47+
})
48+
.collect::<Result<Vec<_>, _>>()?;
4549
let py_args = PyTuple::new_bound(py, py_args);
4650

4751
// 2. call function
@@ -50,7 +54,8 @@ fn pyarrow_function_to_rust(
5054
.map_err(|e| DataFusionError::Execution(format!("{e:?}")))?;
5155

5256
// 3. cast to arrow::array::Array
53-
let array_data = ArrayData::from_pyarrow_bound(value.bind(py)).unwrap();
57+
let array_data = ArrayData::from_pyarrow_bound(value.bind(py))
58+
.map_err(|e| DataFusionError::Execution(format!("{e:?}")))?;
5459
Ok(make_array(array_data))
5560
})
5661
}

0 commit comments

Comments
 (0)