midnattsol commented on issue #6727:
URL: https://github.com/apache/arrow-rs/issues/6727#issuecomment-2505866987
I've updated my code to add the validation in the right place (take instead
of take_impl, what solves the issue for the StructArray and the columns as well
```rust
pub fn take(
values: &dyn Array,
indices: &dyn Array,
options: Option<TakeOptions>,
) -> Result<ArrayRef, ArrowError> {
let options = options.unwrap_or_default();
macro_rules! helper {
($t:ty, $values:expr, $indices:expr, $options:expr) => {{
let indices = indices.as_primitive::<$t>();
if $options.check_bounds {
check_bounds($values.len(), indices)?;
}
if values.nulls().is_none() && indices.null_count() > 0 {
return Err(ArrowError::ComputeError(
"Cannot use null indices on non-nullable
array".to_string(),
));
}
let indices = indices.to_indices();
take_impl($values, &indices)
}};
}
downcast_integer! {
indices.data_type() => (helper, values, indices, options),
d => Err(ArrowError::InvalidArgumentError(format!("Take only
supported for integers, got {d:?}")))
}
}
```
I will open a PR if it looks good for you @gatesn @tustvold
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]