From 4e292c2c5014beba914880559080091aa390acdf Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Thu, 5 Dec 2024 10:39:36 +0100 Subject: [PATCH] Use Option::is_some_and where applicable This will become a clippy warning in the future. --- datafusion/core/src/datasource/listing/url.rs | 3 +-- datafusion/core/src/physical_optimizer/enforce_distribution.rs | 2 +- .../replace_with_order_preserving_variants.rs | 2 +- datafusion/core/src/physical_optimizer/sanity_checker.rs | 2 +- datafusion/physical-expr/src/equivalence/class.rs | 3 +-- datafusion/physical-plan/src/common.rs | 3 +-- 6 files changed, 6 insertions(+), 9 deletions(-) diff --git a/datafusion/core/src/datasource/listing/url.rs b/datafusion/core/src/datasource/listing/url.rs index 2e8d314354c4f..dd3ed62b2f954 100644 --- a/datafusion/core/src/datasource/listing/url.rs +++ b/datafusion/core/src/datasource/listing/url.rs @@ -169,8 +169,7 @@ impl ListingTableUrl { Some(glob) => { if ignore_subdirectory { segments - .next() - .map_or(false, |file_name| glob.matches(file_name)) + .next().is_some_and(|file_name| glob.matches(file_name)) } else { let stripped = segments.join(DELIMITER); glob.matches(&stripped) diff --git a/datafusion/core/src/physical_optimizer/enforce_distribution.rs b/datafusion/core/src/physical_optimizer/enforce_distribution.rs index 82fde60de090c..27323eaedccc4 100644 --- a/datafusion/core/src/physical_optimizer/enforce_distribution.rs +++ b/datafusion/core/src/physical_optimizer/enforce_distribution.rs @@ -617,7 +617,7 @@ pub(crate) fn reorder_join_keys_to_inputs( left.equivalence_properties(), right.equivalence_properties(), ); - if positions.map_or(false, |idxs| !idxs.is_empty()) { + if positions.is_some_and(|idxs| !idxs.is_empty()) { let JoinKeyPairs { left_keys, right_keys, diff --git a/datafusion/core/src/physical_optimizer/replace_with_order_preserving_variants.rs b/datafusion/core/src/physical_optimizer/replace_with_order_preserving_variants.rs index 7fc3adf784e28..2f6b7a51ee751 100644 --- a/datafusion/core/src/physical_optimizer/replace_with_order_preserving_variants.rs +++ b/datafusion/core/src/physical_optimizer/replace_with_order_preserving_variants.rs @@ -162,7 +162,7 @@ fn plan_with_order_breaking_variants( // not required by intermediate operators: if maintains && (is_sort_preserving_merge(plan) - || !required_ordering.map_or(false, |required_ordering| { + || !required_ordering.is_some_and(|required_ordering| { node.plan .equivalence_properties() .ordering_satisfy_requirement(&required_ordering) diff --git a/datafusion/core/src/physical_optimizer/sanity_checker.rs b/datafusion/core/src/physical_optimizer/sanity_checker.rs index b2f2c933c1d15..99bd1cab3ed41 100644 --- a/datafusion/core/src/physical_optimizer/sanity_checker.rs +++ b/datafusion/core/src/physical_optimizer/sanity_checker.rs @@ -103,7 +103,7 @@ pub fn check_finiteness_requirements( /// [`PhysicalExpr`]: crate::physical_plan::PhysicalExpr /// [`Operator`]: datafusion_expr::Operator fn is_prunable(join: &SymmetricHashJoinExec) -> bool { - join.filter().map_or(false, |filter| { + join.filter().is_some_and(|filter| { check_support(filter.expression(), &join.schema()) && filter .schema() diff --git a/datafusion/physical-expr/src/equivalence/class.rs b/datafusion/physical-expr/src/equivalence/class.rs index add6871d1ac44..5be5b9722f7cc 100644 --- a/datafusion/physical-expr/src/equivalence/class.rs +++ b/datafusion/physical-expr/src/equivalence/class.rs @@ -515,8 +515,7 @@ impl EquivalenceGroup { // project. For example, if we have the mapping `(a as a1, a + c)` // and the equivalence class `(a, b)`, expression `b` projects to `a1`. if self - .get_equivalence_class(source) - .map_or(false, |group| group.contains(expr)) + .get_equivalence_class(source).is_some_and(|group| group.contains(expr)) { return Some(Arc::clone(target)); } diff --git a/datafusion/physical-plan/src/common.rs b/datafusion/physical-plan/src/common.rs index 844208999d254..8c5dc9908446d 100644 --- a/datafusion/physical-plan/src/common.rs +++ b/datafusion/physical-plan/src/common.rs @@ -260,8 +260,7 @@ pub fn can_project( Some(columns) => { if columns .iter() - .max() - .map_or(false, |&i| i >= schema.fields().len()) + .max().is_some_and(|&i| i >= schema.fields().len()) { Err(arrow_schema::ArrowError::SchemaError(format!( "project index {} out of bounds, max field {}",