Skip to content

Apache DataFusion SQL Query Engine

toolchain upgrade and error fixes (#15625)

Jyotir Sai9d2f04996604
diff --git a/datafusion-examples/examples/parquet_index.rs b/datafusion-examples/examples/parquet_index.rs
index 0b6bccc27b..7d6ce4d86a 100644
--- a/datafusion-examples/examples/parquet_index.rs
+++ b/datafusion-examples/examples/parquet_index.rs
@@ -685,7 +685,7 @@ fn make_demo_file(path: impl AsRef<Path>, value_range: Range<i32>) -> Result<()>
let num_values = value_range.len();
let file_names =
- StringArray::from_iter_values(std::iter::repeat(&filename).take(num_values));
+ StringArray::from_iter_values(std::iter::repeat_n(&filename, num_values));
let values = Int32Array::from_iter_values(value_range);
let batch = RecordBatch::try_from_iter(vec![
("file_name", Arc::new(file_names) as ArrayRef),
diff --git a/datafusion/common/src/scalar/mod.rs b/datafusion/common/src/scalar/mod.rs
index 4a58530edf..b8d9aea810 100644
--- a/datafusion/common/src/scalar/mod.rs
+++ b/datafusion/common/src/scalar/mod.rs
@@ -27,7 +27,7 @@ use std::convert::Infallible;
use std::fmt;
use std::hash::Hash;
use std::hash::Hasher;
-use std::iter::repeat;
+use std::iter::repeat_n;
use std::mem::{size_of, size_of_val};
use std::str::FromStr;
use std::sync::Arc;
@@ -802,12 +802,14 @@ fn dict_from_scalar<K: ArrowDictionaryKeyType>(
let values_array = value.to_array_of_size(1)?;
// Create a key array with `size` elements, each of 0
- let key_array: PrimitiveArray<K> = repeat(if value.is_null() {
- None
- } else {
- Some(K::default_value())
- })
- .take(size)
+ let key_array: PrimitiveArray<K> = repeat_n(
+ if value.is_null() {
+ None
+ } else {
+ Some(K::default_value())
+ },
+ size,
+ )
.collect();
// create a new DictionaryArray
@@ -2189,8 +2191,7 @@ impl ScalarValue {
scale: i8,
size: usize,
) -> Result<Decimal256Array> {
- Ok(repeat(value)
- .take(size)
+ Ok(repeat_n(value, size)
.collect::<Decimal256Array>()
.with_precision_and_scale(precision, scale)?)
}
@@ -2416,53 +2417,47 @@ impl ScalarValue {
}
ScalarValue::Utf8(e) => match e {
Some(value) => {
- Arc::new(StringArray::from_iter_values(repeat(value).take(size)))
+ Arc::new(StringArray::from_iter_values(repeat_n(value, size)))
}
None => new_null_array(&DataType::Utf8, size),
},
ScalarValue::Utf8View(e) => match e {
Some(value) => {
- Arc::new(StringViewArray::from_iter_values(repeat(value).take(size)))
+ Arc::new(StringViewArray::from_iter_values(repeat_n(value, size)))
}
None => new_null_array(&DataType::Utf8View, size),
},
ScalarValue::LargeUtf8(e) => match e {
Some(value) => {
- Arc::new(LargeStringArray::from_iter_values(repeat(value).take(size)))
+ Arc::new(LargeStringArray::from_iter_values(repeat_n(value, size)))
}
None => new_null_array(&DataType::LargeUtf8, size),
},
ScalarValue::Binary(e) => match e {
Some(value) => Arc::new(
- repeat(Some(value.as_slice()))
- .take(size)
- .collect::<BinaryArray>(),
+ repeat_n(Some(value.as_slice()), size).collect::<BinaryArray>(),
),
- None => {
- Arc::new(repeat(None::<&str>).take(size).collect::<BinaryArray>())
- }
+ None => Arc::new(repeat_n(None::<&str>, size).collect::<BinaryArray>()),
},
ScalarValue::BinaryView(e) => match e {
Some(value) => Arc::new(
- repeat(Some(value.as_slice()))
- .take(size)
- .collect::<BinaryViewArray>(),
+ repeat_n(Some(value.as_slice()), size).collect::<BinaryViewArray>(),
),
None => {
- Arc::new(repeat(None::<&str>).take(size).collect::<BinaryViewArray>())
+ Arc::new(repeat_n(None::<&str>, size).collect::<BinaryViewArray>())
}
},
ScalarValue::FixedSizeBinary(s, e) => match e {
Some(value) => Arc::new(
FixedSizeBinaryArray::try_from_sparse_iter_with_size(
- repeat(Some(value.as_slice())).take(size),
+ repeat_n(Some(value.as_slice()), size),
*s,
)
.unwrap(),
),
None => Arc::new(
FixedSizeBinaryArray::try_from_sparse_iter_with_size(
- repeat(None::<&[u8]>).take(size),
+ repeat_n(None::<&[u8]>, size),
*s,
)
.unwrap(),
@@ -2470,15 +2465,11 @@ impl ScalarValue {
},
ScalarValue::LargeBinary(e) => match e {
Some(value) => Arc::new(
- repeat(Some(value.as_slice()))
- .take(size)
- .collect::<LargeBinaryArray>(),
- ),
- None => Arc::new(
- repeat(None::<&str>)
- .take(size)
- .collect::<LargeBinaryArray>(),
+ repeat_n(Some(value.as_slice()), size).collect::<LargeBinaryArray>(),
),
+ None => {
+ Arc::new(repeat_n(None::<&str>, size).collect::<LargeBinaryArray>())
+ }
},
ScalarValue::List(arr) => {
Self::list_to_array_of_size(arr.as_ref() as &dyn Array, size)?
@@ -2606,7 +2597,7 @@ impl ScalarValue {
child_arrays.push(ar);
new_fields.push(field.clone());
}
- let type_ids = repeat(*v_id).take(size);
+ let type_ids = repeat_n(*v_id, size);
let type_ids = ScalarBuffer::<i8>::from_iter(type_ids);
let value_offsets = match mode {
UnionMode::Sparse => None,
@@ -2674,7 +2665,7 @@ impl ScalarValue {
}
fn list_to_array_of_size(arr: &dyn Array, size: usize) -> Result<ArrayRef> {
- let arrays = repeat(arr).take(size).collect::<Vec<_>>();
+ let arrays = repeat_n(arr, size).collect::<Vec<_>>();
let ret = match !arrays.is_empty() {
true => arrow::compute::concat(arrays.as_slice())?,
false => arr.slice(0, 0),
diff --git a/datafusion/common/src/utils/memory.rs b/datafusion/common/src/utils/memory.rs
index ab73996fcd..7ac081e0be 100644
--- a/datafusion/common/src/utils/memory.rs
+++ b/datafusion/common/src/utils/memory.rs
@@ -25,7 +25,7 @@ use std::mem::size_of;
/// # Parameters
/// - `num_elements`: The number of elements expected in the hash table.
/// - `fixed_size`: A fixed overhead size associated with the collection
-/// (e.g., HashSet or HashTable).
+/// (e.g., HashSet or HashTable).
/// - `T`: The type of elements stored in the hash table.
///
/// # Details
diff --git a/datafusion/core/src/datasource/listing/table.rs b/datafusion/core/src/datasource/listing/table.rs
index cbc7e65d1c..c05b7835ed 100644
--- a/datafusion/core/src/datasource/listing/table.rs
+++ b/datafusion/core/src/datasource/listing/table.rs
@@ -1183,7 +1183,7 @@ impl ListingTable {
/// # Arguments
/// * `files` - A stream of `Result<PartitionedFile>` items to process
/// * `limit` - An optional row count limit. If provided, the function will stop collecting files
-/// once the accumulated number of rows exceeds this limit
+/// once the accumulated number of rows exceeds this limit
/// * `collect_stats` - Whether to collect and accumulate statistics from the files
///
/// # Returns
diff --git a/datafusion/core/src/physical_planner.rs b/datafusion/core/src/physical_planner.rs
index f1a99a7714..ad579315ae 100644
--- a/datafusion/core/src/physical_planner.rs
+++ b/datafusion/core/src/physical_planner.rs
@@ -1023,18 +1023,12 @@ impl DefaultPhysicalPlanner {
// Collect left & right field indices, the field indices are sorted in ascending order
let left_field_indices = cols
.iter()
- .filter_map(|c| match left_df_schema.index_of_column(c) {
- Ok(idx) => Some(idx),
- _ => None,
- })
+ .filter_map(|c| left_df_schema.index_of_column(c).ok())
.sorted()
.collect::<Vec<_>>();
let right_field_indices = cols
.iter()
- .filter_map(|c| match right_df_schema.index_of_column(c) {
- Ok(idx) => Some(idx),
- _ => None,
- })
+ .filter_map(|c| right_df_schema.index_of_column(c).ok())
.sorted()
.collect::<Vec<_>>();
diff --git a/datafusion/core/tests/fuzz_cases/aggregation_fuzzer/context_generator.rs b/datafusion/core/tests/fuzz_cases/aggregation_fuzzer/context_generator.rs
index 8a8aa180b3..3c9fe29172 100644
--- a/datafusion/core/tests/fuzz_cases/aggregation_fuzzer/context_generator.rs
+++ b/datafusion/core/tests/fuzz_cases/aggregation_fuzzer/context_generator.rs
@@ -43,7 +43,7 @@ use crate::fuzz_cases::aggregation_fuzzer::data_generator::Dataset;
/// - `skip_partial parameters`
/// - hint `sorted` or not
/// - `spilling` or not (TODO, I think a special `MemoryPool` may be needed
-/// to support this)
+/// to support this)
///
pub struct SessionContextGenerator {
/// Current testing dataset
diff --git a/datafusion/core/tests/fuzz_cases/aggregation_fuzzer/data_generator.rs b/datafusion/core/tests/fuzz_cases/aggregation_fuzzer/data_generator.rs
index 59f6705e56..82bfe19923 100644
--- a/datafusion/core/tests/fuzz_cases/aggregation_fuzzer/data_generator.rs
+++ b/datafusion/core/tests/fuzz_cases/aggregation_fuzzer/data_generator.rs
@@ -33,12 +33,12 @@ use crate::fuzz_cases::record_batch_generator::{ColumnDescr, RecordBatchGenerato
/// when you call `generate` function
///
/// - `rows_num_range`, the number of rows in the datasets will be randomly generated
-/// within this range
+/// within this range
///
/// - `sort_keys`, if `sort_keys` are defined, when you call the `generate` function, the generator
-/// will generate one `base dataset` firstly. Then the `base dataset` will be sorted
-/// based on each `sort_key` respectively. And finally `len(sort_keys) + 1` datasets
-/// will be returned
+/// will generate one `base dataset` firstly. Then the `base dataset` will be sorted
+/// based on each `sort_key` respectively. And finally `len(sort_keys) + 1` datasets
+/// will be returned
///
#[derive(Debug, Clone)]
pub struct DatasetGeneratorConfig {
diff --git a/datafusion/core/tests/fuzz_cases/aggregation_fuzzer/fuzzer.rs b/datafusion/core/tests/fuzz_cases/aggregation_fuzzer/fuzzer.rs
index 88f0269eb3..1e97ddcdb1 100644
--- a/datafusion/core/tests/fuzz_cases/aggregation_fuzzer/fuzzer.rs
+++ b/datafusion/core/tests/fuzz_cases/aggregation_fuzzer/fuzzer.rs
@@ -270,7 +270,7 @@ impl AggregationFuzzer {
/// - `sql`, the selected test sql
///
/// - `dataset_ref`, the input dataset, store it for error reported when found
-/// the inconsistency between the one for `ctx` and `expected results`.
+/// the inconsistency between the one for `ctx` and `expected results`.
///
struct AggregationFuzzTestTask {
/// Generated session context in current test case
diff --git a/datafusion/core/tests/memory_limit/mod.rs b/datafusion/core/tests/memory_limit/mod.rs
index 0b7d498fa7..01342d1604 100644
--- a/datafusion/core/tests/memory_limit/mod.rs
+++ b/datafusion/core/tests/memory_limit/mod.rs
@@ -863,11 +863,10 @@ impl Scenario {
single_row_batches,
} => {
use datafusion::physical_expr::expressions::col;
- let batches: Vec<Vec<_>> = std::iter::repeat(maybe_split_batches(
- dict_batches(),
- *single_row_batches,
- ))
- .take(*partitions)
+ let batches: Vec<Vec<_>> = std::iter::repeat_n(
+ maybe_split_batches(dict_batches(), *single_row_batches),
+ *partitions,
+ )
.collect();
let schema = batches[0][0].schema();
diff --git a/datafusion/core/tests/parquet/mod.rs b/datafusion/core/tests/parquet/mod.rs
index f45eacce18..87a5ed33f1 100644
--- a/datafusion/core/tests/parquet/mod.rs
+++ b/datafusion/core/tests/parquet/mod.rs
@@ -611,7 +611,7 @@ fn make_bytearray_batch(
large_binary_values: Vec<&[u8]>,
) -> RecordBatch {
let num_rows = string_values.len();
- let name: StringArray = std::iter::repeat(Some(name)).take(num_rows).collect();
+ let name: StringArray = std::iter::repeat_n(Some(name), num_rows).collect();
let service_string: StringArray = string_values.iter().map(Some).collect();
let service_binary: BinaryArray = binary_values.iter().map(Some).collect();
let service_fixedsize: FixedSizeBinaryArray = fixedsize_values
@@ -659,7 +659,7 @@ fn make_bytearray_batch(
/// name | service.name
fn make_names_batch(name: &str, service_name_values: Vec<&str>) -> RecordBatch {
let num_rows = service_name_values.len();
- let name: StringArray = std::iter::repeat(Some(name)).take(num_rows).collect();
+ let name: StringArray = std::iter::repeat_n(Some(name), num_rows).collect();
let service_name: StringArray = service_name_values.iter().map(Some).collect();
let schema = Schema::new(vec![
@@ -698,7 +698,7 @@ fn make_int_batches_with_null(
Int8Array::from_iter(
v8.into_iter()
.map(Some)
- .chain(std::iter::repeat(None).take(null_values)),
+ .chain(std::iter::repeat_n(None, null_values)),
)
.to_data(),
),
@@ -706,7 +706,7 @@ fn make_int_batches_with_null(
Int16Array::from_iter(
v16.into_iter()
.map(Some)
- .chain(std::iter::repeat(None).take(null_values)),
+ .chain(std::iter::repeat_n(None, null_values)),
)
.to_data(),
),
@@ -714,7 +714,7 @@ fn make_int_batches_with_null(
Int32Array::from_iter(
v32.into_iter()
.map(Some)
- .chain(std::iter::repeat(None).take(null_values)),
+ .chain(std::iter::repeat_n(None, null_values)),
)
.to_data(),
),
@@ -722,7 +722,7 @@ fn make_int_batches_with_null(
Int64Array::from_iter(
v64.into_iter()
.map(Some)
- .chain(std::iter::repeat(None).take(null_values)),
+ .chain(std::iter::repeat_n(None, null_values)),
)
.to_data(),
),
diff --git a/datafusion/core/tests/user_defined/user_defined_window_functions.rs b/datafusion/core/tests/user_defined/user_defined_window_functions.rs
index 28394f0b9d..7c56507acd 100644
--- a/datafusion/core/tests/user_defined/user_defined_window_functions.rs
+++ b/datafusion/core/tests/user_defined/user_defined_window_functions.rs
@@ -633,7 +633,7 @@ fn odd_count(arr: &Int64Array) -> i64 {
/// returns an array of num_rows that has the number of odd values in `arr`
fn odd_count_arr(arr: &Int64Array, num_rows: usize) -> ArrayRef {
- let array: Int64Array = std::iter::repeat(odd_count(arr)).take(num_rows).collect();
+ let array: Int64Array = std::iter::repeat_n(odd_count(arr), num_rows).collect();
Arc::new(array)
}
diff --git a/datafusion/datasource/src/schema_adapter.rs b/datafusion/datasource/src/schema_adapter.rs
index 4164cda8cb..eafddecd05 100644
--- a/datafusion/datasource/src/schema_adapter.rs
+++ b/datafusion/datasource/src/schema_adapter.rs
@@ -42,7 +42,7 @@ pub trait SchemaAdapterFactory: Debug + Send + Sync + 'static {
/// Arguments:
///
/// * `projected_table_schema`: The schema for the table, projected to
- /// include only the fields being output (projected) by the this mapping.
+ /// include only the fields being output (projected) by the this mapping.
///
/// * `table_schema`: The entire table schema for the table
fn create(
diff --git a/datafusion/datasource/src/url.rs b/datafusion/datasource/src/url.rs
index 2dbcfa2ef1..bddfdbcc06 100644
--- a/datafusion/datasource/src/url.rs
+++ b/datafusion/datasource/src/url.rs
@@ -209,10 +209,10 @@ impl ListingTableUrl {
/// assert_eq!(url.file_extension(), None);
/// ```
pub fn file_extension(&self) -> Option<&str> {
- if let Some(segments) = self.url.path_segments() {
- if let Some(last_segment) = segments.last() {
+ if let Some(mut segments) = self.url.path_segments() {
+ if let Some(last_segment) = segments.next_back() {
if last_segment.contains(".") && !last_segment.ends_with(".") {
- return last_segment.split('.').last();
+ return last_segment.split('.').next_back();
}
}
}
diff --git a/datafusion/expr-common/src/interval_arithmetic.rs b/datafusion/expr-common/src/interval_arithmetic.rs
index 9d00b45962..6af4322df2 100644
--- a/datafusion/expr-common/src/interval_arithmetic.rs
+++ b/datafusion/expr-common/src/interval_arithmetic.rs
@@ -174,7 +174,7 @@ macro_rules! value_transition {
/// - `INF` values are converted to `NULL`s while constructing an interval to
/// ensure consistency, with other data types.
/// - `NaN` (Not a Number) results are conservatively result in unbounded
-/// endpoints.
+/// endpoints.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Interval {
lower: ScalarValue,
diff --git a/datafusion/expr-common/src/signature.rs b/datafusion/expr-common/src/signature.rs
index 063417a254..a7c9330201 100644
--- a/datafusion/expr-common/src/signature.rs
+++ b/datafusion/expr-common/src/signature.rs
@@ -391,10 +391,11 @@ impl TypeSignature {
vec![format!("{}, ..", Self::join_types(types, "/"))]
}
TypeSignature::Uniform(arg_count, valid_types) => {
- vec![std::iter::repeat(Self::join_types(valid_types, "/"))
- .take(*arg_count)
- .collect::<Vec<String>>()
- .join(", ")]
+ vec![
+ std::iter::repeat_n(Self::join_types(valid_types, "/"), *arg_count)
+ .collect::<Vec<String>>()
+ .join(", "),
+ ]
}
TypeSignature::String(num) => {
vec![format!("String({num})")]
@@ -412,8 +413,7 @@ impl TypeSignature {
vec![Self::join_types(types, ", ")]
}
TypeSignature::Any(arg_count) => {
- vec![std::iter::repeat("Any")
- .take(*arg_count)
+ vec![std::iter::repeat_n("Any", *arg_count)
.collect::<Vec<&str>>()
.join(", ")]
}
diff --git a/datafusion/expr/src/logical_plan/builder.rs b/datafusion/expr/src/logical_plan/builder.rs
index 2f6eaf1c05..64931df5a8 100644
--- a/datafusion/expr/src/logical_plan/builder.rs
+++ b/datafusion/expr/src/logical_plan/builder.rs
@@ -2192,7 +2192,7 @@ pub fn unnest_with_options(
// new columns dependent on the same original index
dependency_indices
- .extend(std::iter::repeat(index).take(transformed_columns.len()));
+ .extend(std::iter::repeat_n(index, transformed_columns.len()));
Ok(transformed_columns
.iter()
.map(|(col, field)| (col.relation.to_owned(), field.to_owned()))
diff --git a/datafusion/ffi/src/table_provider.rs b/datafusion/ffi/src/table_provider.rs
index c86c07ebaa..890511997a 100644
--- a/datafusion/ffi/src/table_provider.rs
+++ b/datafusion/ffi/src/table_provider.rs
@@ -110,8 +110,8 @@ pub struct FFI_TableProvider {
/// * `session_config` - session configuration
/// * `projections` - if specified, only a subset of the columns are returned
/// * `filters_serialized` - filters to apply to the scan, which are a
- /// [`LogicalExprList`] protobuf message serialized into bytes to pass
- /// across the FFI boundary.
+ /// [`LogicalExprList`] protobuf message serialized into bytes to pass
+ /// across the FFI boundary.
/// * `limit` - if specified, limit the number of rows returned
pub scan: unsafe extern "C" fn(
provider: &Self,
diff --git a/datafusion/functions-aggregate/src/array_agg.rs b/datafusion/functions-aggregate/src/array_agg.rs
index 573624ce4d..d658744c1b 100644
--- a/datafusion/functions-aggregate/src/array_agg.rs
+++ b/datafusion/functions-aggregate/src/array_agg.rs
@@ -289,7 +289,7 @@ impl Accumulator for ArrayAggAccumulator {
}
let val = Arc::clone(&values[0]);
- if val.len() > 0 {
+ if !val.is_empty() {
self.values.push(val);
}
Ok(())
@@ -310,7 +310,7 @@ impl Accumulator for ArrayAggAccumulator {
match Self::get_optional_values_to_merge_as_is(list_arr) {
Some(values) => {
// Make sure we don't insert empty lists
- if values.len() > 0 {
+ if !values.is_empty() {
self.values.push(values);
}
}
diff --git a/datafusion/functions-nested/src/array_has.rs b/datafusion/functions-nested/src/array_has.rs
index 48ee341566..5ef1491313 100644
--- a/datafusion/functions-nested/src/array_has.rs
+++ b/datafusion/functions-nested/src/array_has.rs
@@ -271,7 +271,7 @@ fn array_has_dispatch_for_scalar<O: OffsetSizeTrait>(
let offsets = haystack.value_offsets();
// If first argument is empty list (second argument is non-null), return false
// i.e. array_has([], non-null element) -> false
- if values.len() == 0 {
+ if values.is_empty() {
return Ok(Arc::new(BooleanArray::new(
BooleanBuffer::new_unset(haystack.len()),
None,
@@ -488,7 +488,7 @@ fn array_has_all_and_any_dispatch<O: OffsetSizeTrait>(
) -> Result<ArrayRef> {
let haystack = as_generic_list_array::<O>(haystack)?;
let needle = as_generic_list_array::<O>(needle)?;
- if needle.values().len() == 0 {
+ if needle.values().is_empty() {
let buffer = match comparison_type {
ComparisonType::All => BooleanBuffer::new_set(haystack.len()),
ComparisonType::Any => BooleanBuffer::new_unset(haystack.len()),
diff --git a/datafusion/functions-window-common/src/expr.rs b/datafusion/functions-window-common/src/expr.rs
index 1d99fe7acf..76e27b045b 100644
--- a/datafusion/functions-window-common/src/expr.rs
+++ b/datafusion/functions-window-common/src/expr.rs
@@ -36,9 +36,9 @@ impl<'a> ExpressionArgs<'a> {
/// # Arguments
///
/// * `input_exprs` - The expressions passed as arguments
- /// to the user-defined window function.
+ /// to the user-defined window function.
/// * `input_types` - The data types corresponding to the
- /// arguments to the user-defined window function.
+ /// arguments to the user-defined window function.
///
pub fn new(
input_exprs: &'a [Arc<dyn PhysicalExpr>],
diff --git a/datafusion/functions-window-common/src/field.rs b/datafusion/functions-window-common/src/field.rs
index 8011b7b0f0..03f88b0b95 100644
--- a/datafusion/functions-window-common/src/field.rs
+++ b/datafusion/functions-window-common/src/field.rs
@@ -33,9 +33,9 @@ impl<'a> WindowUDFFieldArgs<'a> {
/// # Arguments
///
/// * `input_types` - The data types corresponding to the
- /// arguments to the user-defined window function.
+ /// arguments to the user-defined window function.
/// * `function_name` - The qualified schema name of the
- /// user-defined window function expression.
+ /// user-defined window function expression.
///
pub fn new(input_types: &'a [DataType], display_name: &'a str) -> Self {
WindowUDFFieldArgs {
diff --git a/datafusion/functions-window-common/src/partition.rs b/datafusion/functions-window-common/src/partition.rs
index 64786d2fe7..e853aa8fb0 100644
--- a/datafusion/functions-window-common/src/partition.rs
+++ b/datafusion/functions-window-common/src/partition.rs
@@ -41,13 +41,13 @@ impl<'a> PartitionEvaluatorArgs<'a> {
/// # Arguments
///
/// * `input_exprs` - The expressions passed as arguments
- /// to the user-defined window function.
+ /// to the user-defined window function.
/// * `input_types` - The data types corresponding to the
- /// arguments to the user-defined window function.
+ /// arguments to the user-defined window function.
/// * `is_reversed` - Set to `true` if and only if the user-defined
- /// window function is reversible and is reversed.
+ /// window function is reversible and is reversed.
/// * `ignore_nulls` - Set to `true` when `IGNORE NULLS` is
- /// specified.
+ /// specified.
///
pub fn new(
input_exprs: &'a [Arc<dyn PhysicalExpr>],
diff --git a/datafusion/functions-window/src/cume_dist.rs b/datafusion/functions-window/src/cume_dist.rs
index f4089ee2fd..d156416a82 100644
--- a/datafusion/functions-window/src/cume_dist.rs
+++ b/datafusion/functions-window/src/cume_dist.rs
@@ -128,7 +128,7 @@ impl PartitionEvaluator for CumeDistEvaluator {
let len = range.end - range.start;
*acc += len as u64;
let value: f64 = (*acc as f64) / scalar;
- let result = iter::repeat(value).take(len);
+ let result = iter::repeat_n(value, len);
Some(result)
})
.flatten(),
diff --git a/datafusion/functions-window/src/macros.rs b/datafusion/functions-window/src/macros.rs
index 0a86ba6255..2ef1eacba9 100644
--- a/datafusion/functions-window/src/macros.rs
+++ b/datafusion/functions-window/src/macros.rs
@@ -29,12 +29,12 @@
/// # Parameters
///
/// * `$UDWF`: The struct which defines the [`Signature`](datafusion_expr::Signature)
-/// of the user-defined window function.
+/// of the user-defined window function.
/// * `$OUT_FN_NAME`: The basename to generate a unique function name like
-/// `$OUT_FN_NAME_udwf`.
+/// `$OUT_FN_NAME_udwf`.
/// * `$DOC`: Doc comments for UDWF.
/// * (optional) `$CTOR`: Pass a custom constructor. When omitted it
-/// automatically resolves to `$UDWF::default()`.
+/// automatically resolves to `$UDWF::default()`.
///
/// # Example
///
@@ -122,13 +122,13 @@ macro_rules! get_or_init_udwf {
/// # Parameters
///
/// * `$UDWF`: The struct which defines the [`Signature`] of the
-/// user-defined window function.
+/// user-defined window function.
/// * `$OUT_FN_NAME`: The basename to generate a unique function name like
-/// `$OUT_FN_NAME_udwf`.
+/// `$OUT_FN_NAME_udwf`.
/// * `$DOC`: Doc comments for UDWF.
/// * (optional) `[$($PARAM:ident),+]`: An array of 1 or more parameters
-/// for the generated function. The type of parameters is [`Expr`].
-/// When omitted this creates a function with zero parameters.
+/// for the generated function. The type of parameters is [`Expr`].
+/// When omitted this creates a function with zero parameters.
///
/// [`Signature`]: datafusion_expr::Signature
/// [`Expr`]: datafusion_expr::Expr
@@ -332,15 +332,15 @@ macro_rules! create_udwf_expr {
/// # Arguments
///
/// * `$UDWF`: The struct which defines the [`Signature`] of the
-/// user-defined window function.
+/// user-defined window function.
/// * `$OUT_FN_NAME`: The basename to generate a unique function name like
-/// `$OUT_FN_NAME_udwf`.
+/// `$OUT_FN_NAME_udwf`.
/// * (optional) `[$($PARAM:ident),+]`: An array of 1 or more parameters
-/// for the generated function. The type of parameters is [`Expr`].
-/// When omitted this creates a function with zero parameters.
+/// for the generated function. The type of parameters is [`Expr`].
+/// When omitted this creates a function with zero parameters.
/// * `$DOC`: Doc comments for UDWF.
/// * (optional) `$CTOR`: Pass a custom constructor. When omitted it
-/// automatically resolves to `$UDWF::default()`.
+/// automatically resolves to `$UDWF::default()`.
///
/// [`Signature`]: datafusion_expr::Signature
/// [`Expr`]: datafusion_expr::Expr
diff --git a/datafusion/functions-window/src/rank.rs b/datafusion/functions-window/src/rank.rs
index bd2edc5722..2ff2c31d8c 100644
--- a/datafusion/functions-window/src/rank.rs
+++ b/datafusion/functions-window/src/rank.rs
@@ -261,7 +261,7 @@ impl PartitionEvaluator for RankEvaluator {
.iter()
.scan(1_u64, |acc, range| {
let len = range.end - range.start;
- let result = iter::repeat(*acc).take(len);
+ let result = iter::repeat_n(*acc, len);
*acc += len as u64;
Some(result)
})
@@ -274,7 +274,7 @@ impl PartitionEvaluator for RankEvaluator {
.zip(1u64..)
.flat_map(|(range, rank)| {
let len = range.end - range.start;
- iter::repeat(rank).take(len)
+ iter::repeat_n(rank, len)
}),
)),
@@ -287,7 +287,7 @@ impl PartitionEvaluator for RankEvaluator {
.scan(0_u64, |acc, range| {
let len = range.end - range.start;
let value = (*acc as f64) / (denominator - 1.0).max(1.0);
- let result = iter::repeat(value).take(len);
+ let result = iter::repeat_n(value, len);
*acc += len as u64;
Some(result)
})
diff --git a/datafusion/functions/benches/regx.rs b/datafusion/functions/benches/regx.rs
index 1f99cc3a5f..3a1a6a7117 100644
--- a/datafusion/functions/benches/regx.rs
+++ b/datafusion/functions/benches/regx.rs
@@ -197,7 +197,7 @@ fn criterion_benchmark(c: &mut Criterion) {
let regex = Arc::new(regex(&mut rng)) as ArrayRef;
let flags = Arc::new(flags(&mut rng)) as ArrayRef;
let replacement =
- Arc::new(StringArray::from_iter_values(iter::repeat("XX").take(1000)))
+ Arc::new(StringArray::from_iter_values(iter::repeat_n("XX", 1000)))
as ArrayRef;
b.iter(|| {
@@ -219,9 +219,9 @@ fn criterion_benchmark(c: &mut Criterion) {
let regex = cast(&regex(&mut rng), &DataType::Utf8View).unwrap();
// flags are not allowed to be utf8view according to the function
let flags = Arc::new(flags(&mut rng)) as ArrayRef;
- let replacement = Arc::new(StringViewArray::from_iter_values(
- iter::repeat("XX").take(1000),
- ));
+ let replacement = Arc::new(StringViewArray::from_iter_values(iter::repeat_n(
+ "XX", 1000,
+ )));
b.iter(|| {
black_box(
diff --git a/datafusion/physical-expr/src/equivalence/properties/mod.rs b/datafusion/physical-expr/src/equivalence/properties/mod.rs
index c7c33ba5b2..9cf9897001 100644
--- a/datafusion/physical-expr/src/equivalence/properties/mod.rs
+++ b/datafusion/physical-expr/src/equivalence/properties/mod.rs
@@ -1083,7 +1083,7 @@ impl EquivalenceProperties {
/// # Arguments
///
/// * `mapping` - A reference to `ProjectionMapping` that defines how expressions are mapped
- /// in the projection operation
+ /// in the projection operation
///
/// # Returns
///
diff --git a/datafusion/physical-expr/src/planner.rs b/datafusion/physical-expr/src/planner.rs
index fac83dfc45..8660bff796 100644
--- a/datafusion/physical-expr/src/planner.rs
+++ b/datafusion/physical-expr/src/planner.rs
@@ -102,7 +102,7 @@ use datafusion_expr::{
///
/// * `e` - The logical expression
/// * `input_dfschema` - The DataFusion schema for the input, used to resolve `Column` references
-/// to qualified or unqualified fields by name.
+/// to qualified or unqualified fields by name.
pub fn create_physical_expr(
e: &Expr,
input_dfschema: &DFSchema,
diff --git a/datafusion/physical-optimizer/src/enforce_distribution.rs b/datafusion/physical-optimizer/src/enforce_distribution.rs
index 5e76edad1f..b314b43c6a 100644
--- a/datafusion/physical-optimizer/src/enforce_distribution.rs
+++ b/datafusion/physical-optimizer/src/enforce_distribution.rs
@@ -837,7 +837,7 @@ fn new_join_conditions(
///
/// * `input`: Current node.
/// * `n_target`: desired target partition number, if partition number of the
-/// current executor is less than this value. Partition number will be increased.
+/// current executor is less than this value. Partition number will be increased.
///
/// # Returns
///
@@ -880,7 +880,7 @@ fn add_roundrobin_on_top(
/// * `input`: Current node.
/// * `hash_exprs`: Stores Physical Exprs that are used during hashing.
/// * `n_target`: desired target partition number, if partition number of the
-/// current executor is less than this value. Partition number will be increased.
+/// current executor is less than this value. Partition number will be increased.
///
/// # Returns
///
diff --git a/datafusion/physical-optimizer/src/pruning.rs b/datafusion/physical-optimizer/src/pruning.rs
index b5287f3d33..42d08da20b 100644
--- a/datafusion/physical-optimizer/src/pruning.rs
+++ b/datafusion/physical-optimizer/src/pruning.rs
@@ -312,13 +312,13 @@ pub trait PruningStatistics {
/// * `true`: there MAY be rows that pass the predicate, **KEEPS** the container
///
/// * `NULL`: there MAY be rows that pass the predicate, **KEEPS** the container
-/// Note that rewritten predicate can evaluate to NULL when some of
-/// the min/max values are not known. *Note that this is different than
-/// the SQL filter semantics where `NULL` means the row is filtered
-/// out.*
+/// Note that rewritten predicate can evaluate to NULL when some of
+/// the min/max values are not known. *Note that this is different than
+/// the SQL filter semantics where `NULL` means the row is filtered
+/// out.*
///
/// * `false`: there are no rows that could possibly match the predicate,
-/// **PRUNES** the container
+/// **PRUNES** the container
///
/// For example, given a column `x`, the `x_min`, `x_max`, `x_null_count`, and
/// `x_row_count` represent the minimum and maximum values, the null count of
diff --git a/datafusion/physical-plan/src/aggregates/group_values/multi_group_by/primitive.rs b/datafusion/physical-plan/src/aggregates/group_values/multi_group_by/primitive.rs
index 005dcc8da3..e9c3c42e63 100644
--- a/datafusion/physical-plan/src/aggregates/group_values/multi_group_by/primitive.rs
+++ b/datafusion/physical-plan/src/aggregates/group_values/multi_group_by/primitive.rs
@@ -158,7 +158,7 @@ impl<T: ArrowPrimitiveType, const NULLABLE: bool> GroupColumn
(true, Some(false)) => {
self.nulls.append_n(rows.len(), true);
self.group_values
- .extend(iter::repeat(T::default_value()).take(rows.len()));
+ .extend(iter::repeat_n(T::default_value(), rows.len()));
}
(false, _) => {
diff --git a/datafusion/physical-plan/src/aggregates/order/full.rs b/datafusion/physical-plan/src/aggregates/order/full.rs
index 218855459b..eb98611f79 100644
--- a/datafusion/physical-plan/src/aggregates/order/full.rs
+++ b/datafusion/physical-plan/src/aggregates/order/full.rs
@@ -92,7 +92,7 @@ impl GroupOrderingFull {
Some(EmitTo::First(*current))
}
}
- State::Complete { .. } => Some(EmitTo::All),
+ State::Complete => Some(EmitTo::All),
}
}
@@ -106,7 +106,7 @@ impl GroupOrderingFull {
assert!(*current >= n);
*current -= n;
}
- State::Complete { .. } => panic!("invalid state: complete"),
+ State::Complete => panic!("invalid state: complete"),
}
}
@@ -133,7 +133,7 @@ impl GroupOrderingFull {
current: max_group_index,
}
}
- State::Complete { .. } => {
+ State::Complete => {
panic!("Saw new group after input was complete");
}
};
diff --git a/datafusion/physical-plan/src/aggregates/order/partial.rs b/datafusion/physical-plan/src/aggregates/order/partial.rs
index aff69277a4..c7a75e5f26 100644
--- a/datafusion/physical-plan/src/aggregates/order/partial.rs
+++ b/datafusion/physical-plan/src/aggregates/order/partial.rs
@@ -181,7 +181,7 @@ impl GroupOrderingPartial {
assert!(*current_sort >= n);
*current_sort -= n;
}
- State::Complete { .. } => panic!("invalid state: complete"),
+ State::Complete => panic!("invalid state: complete"),
}
}
diff --git a/datafusion/physical-plan/src/aggregates/row_hash.rs b/datafusion/physical-plan/src/aggregates/row_hash.rs
index 502ea3317a..232565a044 100644
--- a/datafusion/physical-plan/src/aggregates/row_hash.rs
+++ b/datafusion/physical-plan/src/aggregates/row_hash.rs
@@ -975,7 +975,7 @@ impl GroupedHashAggregateStream {
/// memory. Currently only [`GroupOrdering::None`] is supported for spilling.
fn spill_previous_if_necessary(&mut self, batch: &RecordBatch) -> Result<()> {
// TODO: support group_ordering for spilling
- if self.group_values.len() > 0
+ if !self.group_values.is_empty()
&& batch.num_rows() > 0
&& matches!(self.group_ordering, GroupOrdering::None)
&& !self.spill_state.is_stream_merging
diff --git a/datafusion/physical-plan/src/coalesce/mod.rs b/datafusion/physical-plan/src/coalesce/mod.rs
index eb4a7d875c..0eca27f8e4 100644
--- a/datafusion/physical-plan/src/coalesce/mod.rs
+++ b/datafusion/physical-plan/src/coalesce/mod.rs
@@ -90,7 +90,7 @@ impl BatchCoalescer {
/// # Arguments
/// - `schema` - the schema of the output batches
/// - `target_batch_size` - the minimum number of rows for each
- /// output batch (until limit reached)
+ /// output batch (until limit reached)
/// - `fetch` - the maximum number of rows to fetch, `None` means fetch all rows
pub fn new(
schema: SchemaRef,
@@ -285,7 +285,7 @@ mod tests {
fn test_coalesce() {
let batch = uint32_batch(0..8);
Test::new()
- .with_batches(std::iter::repeat(batch).take(10))
+ .with_batches(std::iter::repeat_n(batch, 10))
// expected output is batches of at least 20 rows (except for the final batch)
.with_target_batch_size(21)
.with_expected_output_sizes(vec![24, 24, 24, 8])
@@ -296,7 +296,7 @@ mod tests {
fn test_coalesce_with_fetch_larger_than_input_size() {
let batch = uint32_batch(0..8);
Test::new()
- .with_batches(std::iter::repeat(batch).take(10))
+ .with_batches(std::iter::repeat_n(batch, 10))
// input is 10 batches x 8 rows (80 rows) with fetch limit of 100
// expected to behave the same as `test_concat_batches`
.with_target_batch_size(21)
@@ -309,7 +309,7 @@ mod tests {
fn test_coalesce_with_fetch_less_than_input_size() {
let batch = uint32_batch(0..8);
Test::new()
- .with_batches(std::iter::repeat(batch).take(10))
+ .with_batches(std::iter::repeat_n(batch, 10))
// input is 10 batches x 8 rows (80 rows) with fetch limit of 50
.with_target_batch_size(21)
.with_fetch(Some(50))
@@ -321,7 +321,7 @@ mod tests {
fn test_coalesce_with_fetch_less_than_target_and_no_remaining_rows() {
let batch = uint32_batch(0..8);
Test::new()
- .with_batches(std::iter::repeat(batch).take(10))
+ .with_batches(std::iter::repeat_n(batch, 10))
// input is 10 batches x 8 rows (80 rows) with fetch limit of 48
.with_target_batch_size(21)
.with_fetch(Some(48))
@@ -333,7 +333,7 @@ mod tests {
fn test_coalesce_with_fetch_less_target_batch_size() {
let batch = uint32_batch(0..8);
Test::new()
- .with_batches(std::iter::repeat(batch).take(10))
+ .with_batches(std::iter::repeat_n(batch, 10))
// input is 10 batches x 8 rows (80 rows) with fetch limit of 10
.with_target_batch_size(21)
.with_fetch(Some(10))
diff --git a/datafusion/physical-plan/src/display.rs b/datafusion/physical-plan/src/display.rs
index f437295a35..e247f5ad9d 100644
--- a/datafusion/physical-plan/src/display.rs
+++ b/datafusion/physical-plan/src/display.rs
@@ -657,7 +657,7 @@ impl TreeRenderVisitor<'_, '_> {
}
}
- let halfway_point = (extra_height + 1) / 2;
+ let halfway_point = extra_height.div_ceil(2);
// Render the actual node.
for render_y in 0..=extra_height {
diff --git a/datafusion/physical-plan/src/joins/test_utils.rs b/datafusion/physical-plan/src/joins/test_utils.rs
index e70007aa65..d38637dae0 100644
--- a/datafusion/physical-plan/src/joins/test_utils.rs
+++ b/datafusion/physical-plan/src/joins/test_utils.rs
@@ -444,8 +444,7 @@ pub fn build_sides_record_batches(
.collect::<Vec<i32>>(),
));
let ordered_asc_null_first = Arc::new(Int32Array::from_iter({
- std::iter::repeat(None)
- .take(index as usize)
+ std::iter::repeat_n(None, index as usize)
.chain(rest_of.clone().map(Some))
.collect::<Vec<Option<i32>>>()
}));
@@ -453,13 +452,12 @@ pub fn build_sides_record_batches(
rest_of
.clone()
.map(Some)
- .chain(std::iter::repeat(None).take(index as usize))
+ .chain(std::iter::repeat_n(None, index as usize))
.collect::<Vec<Option<i32>>>()
}));
let ordered_desc_null_first = Arc::new(Int32Array::from_iter({
- std::iter::repeat(None)
- .take(index as usize)
+ std::iter::repeat_n(None, index as usize)
.chain(rest_of.rev().map(Some))
.collect::<Vec<Option<i32>>>()
}));
diff --git a/datafusion/proto/src/physical_plan/from_proto.rs b/datafusion/proto/src/physical_plan/from_proto.rs
index c949e3c9f8..cb4017afae 100644
--- a/datafusion/proto/src/physical_plan/from_proto.rs
+++ b/datafusion/proto/src/physical_plan/from_proto.rs
@@ -67,7 +67,7 @@ impl From<&protobuf::PhysicalColumn> for Column {
/// * `proto` - Input proto with physical sort expression node
/// * `registry` - A registry knows how to build logical expressions out of user-defined function names
/// * `input_schema` - The Arrow schema for the input, used for determining expression data types
-/// when performing type coercion.
+/// when performing type coercion.
/// * `codec` - An extension codec used to decode custom UDFs.
pub fn parse_physical_sort_expr(
proto: &protobuf::PhysicalSortExprNode,
@@ -94,7 +94,7 @@ pub fn parse_physical_sort_expr(
/// * `proto` - Input proto with vector of physical sort expression node
/// * `registry` - A registry knows how to build logical expressions out of user-defined function names
/// * `input_schema` - The Arrow schema for the input, used for determining expression data types
-/// when performing type coercion.
+/// when performing type coercion.
/// * `codec` - An extension codec used to decode custom UDFs.
pub fn parse_physical_sort_exprs(
proto: &[protobuf::PhysicalSortExprNode],
@@ -118,7 +118,7 @@ pub fn parse_physical_sort_exprs(
/// * `name` - Name of the window expression.
/// * `registry` - A registry knows how to build logical expressions out of user-defined function names
/// * `input_schema` - The Arrow schema for the input, used for determining expression data types
-/// when performing type coercion.
+/// when performing type coercion.
/// * `codec` - An extension codec used to decode custom UDFs.
pub fn parse_physical_window_expr(
proto: &protobuf::PhysicalWindowExprNode,
@@ -203,7 +203,7 @@ where
/// * `proto` - Input proto with physical expression node
/// * `registry` - A registry knows how to build logical expressions out of user-defined function names
/// * `input_schema` - The Arrow schema for the input, used for determining expression data types
-/// when performing type coercion.
+/// when performing type coercion.
/// * `codec` - An extension codec used to decode custom UDFs.
pub fn parse_physical_expr(
proto: &protobuf::PhysicalExprNode,
diff --git a/datafusion/proto/tests/cases/serialize.rs b/datafusion/proto/tests/cases/serialize.rs
index d1b50105d0..d15e62909f 100644
--- a/datafusion/proto/tests/cases/serialize.rs
+++ b/datafusion/proto/tests/cases/serialize.rs
@@ -260,7 +260,7 @@ fn test_expression_serialization_roundtrip() {
for function in string::functions() {
// default to 4 args (though some exprs like substr have error checking)
let num_args = 4;
- let args: Vec<_> = std::iter::repeat(&lit).take(num_args).cloned().collect();
+ let args: Vec<_> = std::iter::repeat_n(&lit, num_args).cloned().collect();
let expr = Expr::ScalarFunction(ScalarFunction::new_udf(function, args));
let extension_codec = DefaultLogicalExtensionCodec {};
diff --git a/datafusion/sql/src/expr/value.rs b/datafusion/sql/src/expr/value.rs
index d53691ef05..be4a45a257 100644
--- a/datafusion/sql/src/expr/value.rs
+++ b/datafusion/sql/src/expr/value.rs
@@ -301,7 +301,7 @@ fn interval_literal(interval_value: SQLExpr, negative: bool) -> Result<String> {
fn try_decode_hex_literal(s: &str) -> Option<Vec<u8>> {
let hex_bytes = s.as_bytes();
- let mut decoded_bytes = Vec::with_capacity((hex_bytes.len() + 1) / 2);
+ let mut decoded_bytes = Vec::with_capacity(hex_bytes.len().div_ceil(2));
let start_idx = hex_bytes.len() % 2;
if start_idx > 0 {
diff --git a/datafusion/sql/src/planner.rs b/datafusion/sql/src/planner.rs
index 180017ee9c..3325c98aa7 100644
--- a/datafusion/sql/src/planner.rs
+++ b/datafusion/sql/src/planner.rs
@@ -331,7 +331,7 @@ impl PlannerContext {
///
/// Key interfaces are:
/// * [`Self::sql_statement_to_plan`]: Convert a statement
-/// (e.g. `SELECT ...`) into a [`LogicalPlan`]
+/// (e.g. `SELECT ...`) into a [`LogicalPlan`]
/// * [`Self::sql_to_expr`]: Convert an expression (e.g. `1 + 2`) into an [`Expr`]
pub struct SqlToRel<'a, S: ContextProvider> {
pub(crate) context_provider: &'a S,
diff --git a/datafusion/sql/src/select.rs b/datafusion/sql/src/select.rs
index 85dba0f430..d5a55e0325 100644
--- a/datafusion/sql/src/select.rs
+++ b/datafusion/sql/src/select.rs
@@ -759,11 +759,11 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
/// # Arguments
///
/// * `input` - The input plan that will be aggregated. The grouping, aggregate, and
- /// "having" expressions must all be resolvable from this plan.
+ /// "having" expressions must all be resolvable from this plan.
/// * `select_exprs` - The projection expressions from the SELECT clause.
/// * `having_expr_opt` - Optional HAVING clause.
/// * `group_by_exprs` - Grouping expressions from the GROUP BY clause. These can be column
- /// references or more complex expressions.
+ /// references or more complex expressions.
/// * `aggr_exprs` - Aggregate expressions, such as `SUM(a)` or `COUNT(1)`.
///
/// # Return
@@ -772,9 +772,9 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
///
/// * `plan` - A [LogicalPlan::Aggregate] plan for the newly created aggregate.
/// * `select_exprs_post_aggr` - The projection expressions rewritten to reference columns from
- /// the aggregate
+ /// the aggregate
/// * `having_expr_post_aggr` - The "having" expression rewritten to reference a column from
- /// the aggregate
+ /// the aggregate
fn aggregate(
&self,
input: &LogicalPlan,
diff --git a/datafusion/sql/src/statement.rs b/datafusion/sql/src/statement.rs
index 9685e55a06..1f1c235fee 100644
--- a/datafusion/sql/src/statement.rs
+++ b/datafusion/sql/src/statement.rs
@@ -1034,7 +1034,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
TransactionMode::AccessMode(_) => None,
TransactionMode::IsolationLevel(level) => Some(level),
})
- .last()
+ .next_back()
.copied()
.unwrap_or(ast::TransactionIsolationLevel::Serializable);
let access_mode: ast::TransactionAccessMode = modes
@@ -1043,7 +1043,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
TransactionMode::AccessMode(mode) => Some(mode),
TransactionMode::IsolationLevel(_) => None,
})
- .last()
+ .next_back()
.copied()
.unwrap_or(ast::TransactionAccessMode::ReadWrite);
let isolation_level = match isolation_level {
@@ -1340,11 +1340,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
let options_map = self.parse_options_map(statement.options, true)?;
let maybe_file_type = if let Some(stored_as) = &statement.stored_as {
- if let Ok(ext_file_type) = self.context_provider.get_file_type(stored_as) {
- Some(ext_file_type)
- } else {
- None
- }
+ self.context_provider.get_file_type(stored_as).ok()
} else {
None
};
diff --git a/datafusion/sql/src/unparser/mod.rs b/datafusion/sql/src/unparser/mod.rs
index f90efd103b..05b472dc92 100644
--- a/datafusion/sql/src/unparser/mod.rs
+++ b/datafusion/sql/src/unparser/mod.rs
@@ -118,9 +118,9 @@ impl<'a> Unparser<'a> {
/// The child unparsers are called iteratively.
/// There are two methods in [`Unparser`] will be called:
/// - `extension_to_statement`: This method is called when the custom logical node is a custom statement.
- /// If multiple child unparsers return a non-None value, the last unparsing result will be returned.
+ /// If multiple child unparsers return a non-None value, the last unparsing result will be returned.
/// - `extension_to_sql`: This method is called when the custom logical node is part of a statement.
- /// If multiple child unparsers are registered for the same custom logical node, all of them will be called in order.
+ /// If multiple child unparsers are registered for the same custom logical node, all of them will be called in order.
pub fn with_extension_unparsers(
mut self,
extension_unparsers: Vec<Arc<dyn UserDefinedLogicalNodeUnparser>>,
diff --git a/datafusion/sql/src/unparser/plan.rs b/datafusion/sql/src/unparser/plan.rs
index a6d89638ff..c41effa478 100644
--- a/datafusion/sql/src/unparser/plan.rs
+++ b/datafusion/sql/src/unparser/plan.rs
@@ -900,9 +900,9 @@ impl Unparser<'_> {
/// Try to find the placeholder column name generated by `RecursiveUnnestRewriter`.
///
/// - If the column is a placeholder column match the pattern `Expr::Alias(Expr::Column("__unnest_placeholder(...)"))`,
- /// it means it is a scalar column, return [UnnestInputType::Scalar].
+ /// it means it is a scalar column, return [UnnestInputType::Scalar].
/// - If the column is a placeholder column match the pattern `Expr::Alias(Expr::Column("__unnest_placeholder(outer_ref(...)))")`,
- /// it means it is an outer reference column, return [UnnestInputType::OuterReference].
+ /// it means it is an outer reference column, return [UnnestInputType::OuterReference].
/// - If the column is not a placeholder column, return [None].
///
/// `outer_ref` is the display result of [Expr::OuterReferenceColumn]
diff --git a/datafusion/sqllogictest/bin/sqllogictests.rs b/datafusion/sqllogictest/bin/sqllogictests.rs
index 5894ec056a..21dfe2ee08 100644
--- a/datafusion/sqllogictest/bin/sqllogictests.rs
+++ b/datafusion/sqllogictest/bin/sqllogictests.rs
@@ -175,12 +175,7 @@ async fn run_tests() -> Result<()> {
futures::stream::iter(match result {
// Tokio panic error
Err(e) => Some(DataFusionError::External(Box::new(e))),
- Ok(thread_result) => match thread_result {
- // Test run error
- Err(e) => Some(e),
- // success
- Ok(_) => None,
- },
+ Ok(thread_result) => thread_result.err(),
})
})
.collect()
diff --git a/rust-toolchain.toml b/rust-toolchain.toml
index 11f4fb798c..a85e6fa542 100644
--- a/rust-toolchain.toml
+++ b/rust-toolchain.toml
@@ -19,5 +19,5 @@
# to compile this workspace and run CI jobs.
[toolchain]
-channel = "1.85.0"
+channel = "1.86.0"
components = ["rustfmt", "clippy"]
diff --git a/test-utils/src/lib.rs b/test-utils/src/lib.rs
index 9db8920833..47f23de495 100644
--- a/test-utils/src/lib.rs
+++ b/test-utils/src/lib.rs
@@ -67,10 +67,9 @@ pub fn add_empty_batches(
.flat_map(|batch| {
// insert 0, or 1 empty batches before and after the current batch
let empty_batch = RecordBatch::new_empty(schema.clone());
- std::iter::repeat(empty_batch.clone())
- .take(rng.gen_range(0..2))
+ std::iter::repeat_n(empty_batch.clone(), rng.gen_range(0..2))
.chain(std::iter::once(batch))
- .chain(std::iter::repeat(empty_batch).take(rng.gen_range(0..2)))
+ .chain(std::iter::repeat_n(empty_batch, rng.gen_range(0..2)))
})
.collect()
}