Apache DataFusion SQL Query Engine
minor: remove useless `.get()` (#5336)
jakevinae89960bc9f5
diff --git a/datafusion/optimizer/src/propagate_empty_relation.rs b/datafusion/optimizer/src/propagate_empty_relation.rsindex 8214298a04..4e4280ee80 100644--- a/datafusion/optimizer/src/propagate_empty_relation.rs+++ b/datafusion/optimizer/src/propagate_empty_relation.rs@@ -144,14 +144,8 @@ impl OptimizerRule for PropagateEmptyRelation {}fn binary_plan_children_is_empty(plan: &LogicalPlan) -> Result<(bool, bool)> {- let inputs = plan.inputs();-- // all binary-plan need to deal with separately.- match inputs.len() {- 2 => {- let left = inputs.get(0).unwrap();- let right = inputs.get(1).unwrap();-+ match plan.inputs()[..] {+ [left, right] => {let left_empty = match left {LogicalPlan::EmptyRelation(empty) => !empty.produce_one_row,_ => false,@@ -169,26 +163,20 @@ fn binary_plan_children_is_empty(plan: &LogicalPlan) -> Result<(bool, bool)> {}fn empty_child(plan: &LogicalPlan) -> Result<Option<LogicalPlan>> {- let inputs = plan.inputs();-- // all binary-plan need to deal with separately.- match inputs.len() {- 1 => {- let input = inputs.get(0).unwrap();- match input {- LogicalPlan::EmptyRelation(empty) => {- if !empty.produce_one_row {- Ok(Some(LogicalPlan::EmptyRelation(EmptyRelation {- produce_one_row: false,- schema: plan.schema().clone(),- })))- } else {- Ok(None)- }+ match plan.inputs()[..] {+ [child] => match child {+ LogicalPlan::EmptyRelation(empty) => {+ if !empty.produce_one_row {+ Ok(Some(LogicalPlan::EmptyRelation(EmptyRelation {+ produce_one_row: false,+ schema: plan.schema().clone(),+ })))+ } else {+ Ok(None)}- _ => Ok(None),}- }+ _ => Ok(None),+ },_ => Err(DataFusionError::Plan("plan just can have one child".to_string(),)),diff --git a/datafusion/optimizer/src/push_down_filter.rs b/datafusion/optimizer/src/push_down_filter.rsindex 7136b6ae03..8e90a683f7 100644--- a/datafusion/optimizer/src/push_down_filter.rs+++ b/datafusion/optimizer/src/push_down_filter.rs@@ -561,9 +561,7 @@ impl OptimizerRule for PushDownFilter {| LogicalPlan::Sort(_) => {// commutablelet new_filter =- plan.with_new_inputs(&[- (**(child_plan.inputs().get(0).unwrap())).clone()- ])?;+ plan.with_new_inputs(&[child_plan.inputs()[0].clone()])?;child_plan.with_new_inputs(&[new_filter])?}LogicalPlan::SubqueryAlias(subquery_alias) => {diff --git a/datafusion/optimizer/src/push_down_limit.rs b/datafusion/optimizer/src/push_down_limit.rsindex 9fbc61fc5c..6703a1d787 100644--- a/datafusion/optimizer/src/push_down_limit.rs+++ b/datafusion/optimizer/src/push_down_limit.rs@@ -198,9 +198,7 @@ impl OptimizerRule for PushDownLimit {LogicalPlan::Projection(_) | LogicalPlan::SubqueryAlias(_) => {// commutelet new_limit =- plan.with_new_inputs(&[- (*(child_plan.inputs().get(0).unwrap())).clone()- ])?;+ plan.with_new_inputs(&[child_plan.inputs()[0].clone()])?;Some(child_plan.with_new_inputs(&[new_limit])?)}_ => None,