jorgecarleitao commented on a change in pull request #7998:
URL: https://github.com/apache/arrow/pull/7998#discussion_r472623200



##########
File path: rust/datafusion/src/execution/physical_plan/filter.rs
##########
@@ -15,41 +15,49 @@
 // specific language governing permissions and limitations
 // under the License.
 
-//! Defines the selection execution plan. A selection filters rows based on a 
predicate
+//! FilterExec evaluates a boolean condition against all input batches to 
determine which rows to
+//! include in its output batches.
 
 use std::sync::{Arc, Mutex};
 
 use crate::error::{ExecutionError, Result};
 use crate::execution::physical_plan::{ExecutionPlan, Partition, PhysicalExpr};
 use arrow::array::BooleanArray;
 use arrow::compute::filter;
-use arrow::datatypes::SchemaRef;
+use arrow::datatypes::{DataType, SchemaRef};
 use arrow::error::Result as ArrowResult;
 use arrow::record_batch::{RecordBatch, RecordBatchReader};
 
-/// Execution plan for a Selection
+/// FilterExec evaluates a boolean condition against all input batches to 
determine which rows to
+/// include in its output batches.
 #[derive(Debug)]
-pub struct SelectionExec {
-    /// The selection predicate expression
-    expr: Arc<dyn PhysicalExpr>,
+pub struct FilterExec {
+    /// The expression to filter on. This expression must evaluate to a 
boolean value.
+    condition: Arc<dyn PhysicalExpr>,
     /// The input plan
     input: Arc<dyn ExecutionPlan>,
 }
 
-impl SelectionExec {
-    /// Create a selection on an input
+impl FilterExec {
+    /// Create a FilterExec on an input
     pub fn try_new(
-        expr: Arc<dyn PhysicalExpr>,
+        condition: Arc<dyn PhysicalExpr>,
         input: Arc<dyn ExecutionPlan>,
     ) -> Result<Self> {
-        Ok(Self {
-            expr: expr.clone(),
-            input: input.clone(),
-        })
+        match condition.data_type(input.schema().as_ref())? {
+            DataType::Boolean => Ok(Self {
+                condition: condition.clone(),
+                input: input.clone(),
+            }),
+            other => Err(ExecutionError::General(format!(
+                "Filter condition must return boolean values, not {:?}",
+                other
+            ))),
+        }
     }
 }
 
-impl ExecutionPlan for SelectionExec {
+impl ExecutionPlan for FilterExec {
     /// Get the schema for this execution plan
     fn schema(&self) -> SchemaRef {
         // The selection operator does not make any changes to the schema of 
its input

Review comment:
       `selection`




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to