tustvold commented on a change in pull request #1248:
URL: https://github.com/apache/arrow-rs/pull/1248#discussion_r795106705



##########
File path: arrow/src/compute/kernels/filter.rs
##########
@@ -180,37 +246,146 @@ pub fn prep_null_mask_filter(filter: &BooleanArray) -> 
BooleanArray {
 /// # Ok(())
 /// # }
 /// ```
-pub fn filter(array: &dyn Array, predicate: &BooleanArray) -> Result<ArrayRef> 
{
+pub fn filter(values: &dyn Array, predicate: &BooleanArray) -> 
Result<ArrayRef> {
     if predicate.null_count() > 0 {
         // this greatly simplifies subsequent filtering code
         // now we only have a boolean mask to deal with
         let predicate = prep_null_mask_filter(predicate);
-        return filter(array, &predicate);
+        return filter(values, &predicate);
+    }
+
+    if predicate.len() > values.len() {
+        return Err(ArrowError::InvalidArgumentError(format!(
+            "Filter predicate of length {} is larger than target array of 
length {}",
+            predicate.len(),
+            values.len()
+        )));
     }
 
     let filter_count = filter_count(predicate);
 
     match filter_count {
         0 => {
             // return empty
-            Ok(new_empty_array(array.data_type()))
+            Ok(new_empty_array(values.data_type()))
         }
-        len if len == array.len() => {
+        len if len == values.len() => {
             // return all
-            let data = array.data().clone();
+            let data = values.data().clone();
             Ok(make_array(data))
         }
-        _ => {
-            // actually filter
-            let mut mutable =
-                MutableArrayData::new(vec![array.data_ref()], false, 
filter_count);
+        // actually filter
+        _ => match values.data_type() {

Review comment:
       This block is copied straight from the take kernel - there is probably a 
way to avoid this duplication with some more layers of macros  




-- 
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]


Reply via email to