diff --git a/datafusion/core/src/datasource/listing/url.rs b/datafusion/core/src/datasource/listing/url.rs index 2e8d314354c4..6fb536ca2f05 100644 --- a/datafusion/core/src/datasource/listing/url.rs +++ b/datafusion/core/src/datasource/listing/url.rs @@ -170,7 +170,7 @@ impl ListingTableUrl { if ignore_subdirectory { segments .next() - .map_or(false, |file_name| glob.matches(file_name)) + .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 82fde60de090..27323eaedccc 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 7fc3adf784e2..2f6b7a51ee75 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 b2f2c933c1d1..99bd1cab3ed4 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/functions/src/string/common.rs b/datafusion/functions/src/string/common.rs index 0d1f90eb22b9..6e5f767013d4 100644 --- a/datafusion/functions/src/string/common.rs +++ b/datafusion/functions/src/string/common.rs @@ -61,7 +61,7 @@ pub(crate) fn general_trim( str::trim_start_matches::<&[char]>(input, pattern.as_ref()); // `ltrimmed_str` is actually `input`[start_offset..], // so `start_offset` = len(`input`) - len(`ltrimmed_str`) - let start_offset = input.as_bytes().len() - ltrimmed_str.as_bytes().len(); + let start_offset = input.len() - ltrimmed_str.len(); (ltrimmed_str, start_offset as u32) }, @@ -78,7 +78,7 @@ pub(crate) fn general_trim( str::trim_start_matches::<&[char]>(input, pattern.as_ref()); // `btrimmed_str` can be got by rtrim(ltrim(`input`)), // so its `start_offset` should be same as ltrim situation above - let start_offset = input.as_bytes().len() - ltrimmed_str.as_bytes().len(); + let start_offset = input.len() - ltrimmed_str.len(); let btrimmed_str = str::trim_end_matches::<&[char]>(ltrimmed_str, pattern.as_ref()); diff --git a/datafusion/functions/src/unicode/strpos.rs b/datafusion/functions/src/unicode/strpos.rs index 1917cd7291cc..5d1986e44c92 100644 --- a/datafusion/functions/src/unicode/strpos.rs +++ b/datafusion/functions/src/unicode/strpos.rs @@ -173,13 +173,13 @@ where // the sub vector in the main vector. This is faster than string.find() method. if ascii_only { // If the substring is empty, the result is 1. - if substring.as_bytes().is_empty() { + if substring.is_empty() { T::Native::from_usize(1) } else { T::Native::from_usize( string .as_bytes() - .windows(substring.as_bytes().len()) + .windows(substring.len()) .position(|w| w == substring.as_bytes()) .map(|x| x + 1) .unwrap_or(0), diff --git a/datafusion/physical-expr/src/equivalence/class.rs b/datafusion/physical-expr/src/equivalence/class.rs index 1812844d98c9..d06a495d970a 100644 --- a/datafusion/physical-expr/src/equivalence/class.rs +++ b/datafusion/physical-expr/src/equivalence/class.rs @@ -518,7 +518,7 @@ impl EquivalenceGroup { // and the equivalence class `(a, b)`, expression `b` projects to `a1`. if self .get_equivalence_class(source) - .map_or(false, |group| group.contains(expr)) + .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 844208999d25..aefb90d1d1b7 100644 --- a/datafusion/physical-plan/src/common.rs +++ b/datafusion/physical-plan/src/common.rs @@ -261,7 +261,7 @@ pub fn can_project( if columns .iter() .max() - .map_or(false, |&i| i >= schema.fields().len()) + .is_some_and(|&i| i >= schema.fields().len()) { Err(arrow_schema::ArrowError::SchemaError(format!( "project index {} out of bounds, max field {}",