File tree Expand file tree Collapse file tree 1 file changed +22
-24
lines changed
Expand file tree Collapse file tree 1 file changed +22
-24
lines changed Original file line number Diff line number Diff line change @@ -52,37 +52,35 @@ impl PythonType {
5252 Self :: Bool => {
5353 let array = as_boolean_array ( array) ?;
5454
55- let it = ( 0 ..array. len ( ) ) . map ( move |idx| {
56- if array. is_null ( idx) {
57- Ok ( None )
58- } else {
59- let val = array. value ( idx) ;
60- match val. into_bound_py_any ( py) {
61- Ok ( val) => Ok ( Some ( val) ) ,
62- Err ( e) => Err ( exec_datafusion_err ! (
63- "cannot convert Rust `bool` value to Python: {e}"
64- ) ) ,
65- }
66- }
55+ let it = array. into_iter ( ) . map ( move |maybe_val| {
56+ maybe_val
57+ . map ( |val| {
58+ val. into_bound_py_any ( py) . map_err ( |e| {
59+ exec_datafusion_err ! (
60+ "cannot convert Rust `bool` value to Python: {e}"
61+ )
62+ } )
63+ } )
64+ . transpose ( )
6765 } ) ;
66+
6867 Ok ( Box :: new ( it) )
6968 }
7069 Self :: Int => {
7170 let array = as_int64_array ( array) ?;
7271
73- let it = ( 0 ..array. len ( ) ) . map ( move |idx| {
74- if array. is_null ( idx) {
75- Ok ( None )
76- } else {
77- let val = array. value ( idx) ;
78- match val. into_bound_py_any ( py) {
79- Ok ( val) => Ok ( Some ( val) ) ,
80- Err ( e) => Err ( exec_datafusion_err ! (
81- "cannot convert Rust `i64` value to Python: {e}"
82- ) ) ,
83- }
84- }
72+ let it = array. into_iter ( ) . map ( move |maybe_val| {
73+ maybe_val
74+ . map ( |val| {
75+ val. into_bound_py_any ( py) . map_err ( |e| {
76+ exec_datafusion_err ! (
77+ "cannot convert Rust `i64` value to Python: {e}"
78+ )
79+ } )
80+ } )
81+ . transpose ( )
8582 } ) ;
83+
8684 Ok ( Box :: new ( it) )
8785 }
8886 }
You can’t perform that action at this time.
0 commit comments