You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2022/11/01 14:27:22 UTC

[arrow-datafusion] branch master updated: clean (#4055)

This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git


The following commit(s) were added to refs/heads/master by this push:
     new 525ac4567 clean (#4055)
525ac4567 is described below

commit 525ac4567ad8d86ad085d8439d890b1f9e9e6bb9
Author: Remzi Yang <59...@users.noreply.github.com>
AuthorDate: Tue Nov 1 22:27:16 2022 +0800

    clean (#4055)
    
    Signed-off-by: remzi <13...@gmail.com>
    
    Signed-off-by: remzi <13...@gmail.com>
---
 datafusion/optimizer/src/eliminate_filter.rs | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/datafusion/optimizer/src/eliminate_filter.rs b/datafusion/optimizer/src/eliminate_filter.rs
index 6c0c51b86..862ca195e 100644
--- a/datafusion/optimizer/src/eliminate_filter.rs
+++ b/datafusion/optimizer/src/eliminate_filter.rs
@@ -43,29 +43,22 @@ impl OptimizerRule for EliminateFilter {
         plan: &LogicalPlan,
         optimizer_config: &mut OptimizerConfig,
     ) -> Result<LogicalPlan> {
-        let (filter_value, input) = match plan {
+        let predicate_and_input = match plan {
             LogicalPlan::Filter(filter) => match filter.predicate() {
                 Expr::Literal(ScalarValue::Boolean(Some(v))) => {
-                    (Some(*v), Some(filter.input()))
+                    Some((*v, filter.input()))
                 }
-                _ => (None, None),
+                _ => None,
             },
-            _ => (None, None),
+            _ => None,
         };
 
-        match filter_value {
-            Some(v) => {
-                // input is guaranteed be Some due to previous code
-                let input = input.unwrap();
-                if v {
-                    self.optimize(input, optimizer_config)
-                } else {
-                    Ok(LogicalPlan::EmptyRelation(EmptyRelation {
-                        produce_one_row: false,
-                        schema: input.schema().clone(),
-                    }))
-                }
-            }
+        match predicate_and_input {
+            Some((true, input)) => self.optimize(input, optimizer_config),
+            Some((false, input)) => Ok(LogicalPlan::EmptyRelation(EmptyRelation {
+                produce_one_row: false,
+                schema: input.schema().clone(),
+            })),
             None => {
                 // Apply the optimization to all inputs of the plan
                 let inputs = plan.inputs();