alamb commented on code in PR #2307: URL: https://github.com/apache/arrow-rs/pull/2307#discussion_r937164448
########## arrow/src/compute/kernels/take.rs: ########## @@ -614,23 +614,41 @@ where let mut output_buffer = MutableBuffer::new_null(len); let output_slice = output_buffer.as_slice_mut(); - indices - .iter() - .enumerate() - .try_for_each::<_, Result<()>>(|(i, index)| { - if let Some(index) = index { - let index = ToPrimitive::to_usize(&index).ok_or_else(|| { + let indices_has_nulls = indices.null_count() > 0; + + if indices_has_nulls { + indices + .iter() + .enumerate() + .try_for_each::<_, Result<()>>(|(i, index)| { + if let Some(index) = index { + let index = ToPrimitive::to_usize(&index).ok_or_else(|| { Review Comment: Perhaps more rust like: ```rust ToPrimitive::try_to_usize(&index)? ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org