Skip to content

Commit

Permalink
remove use of .unwrap() from pyarrow_function_to_rust
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-J-Ward committed Oct 12, 2024
1 parent 7bab0a3 commit 25dfafc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ fn pyarrow_function_to_rust(
// 1. cast args to Pyarrow arrays
let py_args = args
.iter()
.map(|arg| arg.into_data().to_pyarrow(py).unwrap())
.collect::<Vec<_>>();
.map(|arg| {
arg.into_data()
.to_pyarrow(py)
.map_err(|e| DataFusionError::Execution(format!("{e:?}")))
})
.collect::<Result<Vec<_>, _>>()?;
let py_args = PyTuple::new_bound(py, py_args);

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

// 3. cast to arrow::array::Array
let array_data = ArrayData::from_pyarrow_bound(value.bind(py)).unwrap();
let array_data = ArrayData::from_pyarrow_bound(value.bind(py))
.map_err(|e| DataFusionError::Execution(format!("{e:?}")))?;
Ok(make_array(array_data))
})
}
Expand Down

0 comments on commit 25dfafc

Please sign in to comment.