This is an automated email from the ASF dual-hosted git repository.
dheres pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new ae89960bc minor: remove useless `.get()` (#5336)
ae89960bc is described below
commit ae89960bc9f59706941be32afa730a87f7e47f1b
Author: jakevin <[email protected]>
AuthorDate: Mon Feb 20 16:23:06 2023 +0800
minor: remove useless `.get()` (#5336)
---
.../optimizer/src/propagate_empty_relation.rs | 40 ++++++++--------------
datafusion/optimizer/src/push_down_filter.rs | 4 +--
datafusion/optimizer/src/push_down_limit.rs | 4 +--
3 files changed, 16 insertions(+), 32 deletions(-)
diff --git a/datafusion/optimizer/src/propagate_empty_relation.rs
b/datafusion/optimizer/src/propagate_empty_relation.rs
index 8214298a0..4e4280ee8 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.rs
index 7136b6ae0..8e90a683f 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(_) => {
// commutable
let 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.rs
index 9fbc61fc5..6703a1d78 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(_) => {
// commute
let 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,