This is an automated email from the ASF dual-hosted git repository.
Jefffrey pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 95b7399896 Enable a few more clippy lints (#10558)
95b7399896 is described below
commit 95b73998969ce26a0916a10db67b072ea592d729
Author: Emil Ernerfeldt <[email protected]>
AuthorDate: Fri Aug 7 05:40:50 2026 -0700
Enable a few more clippy lints (#10558)
# Which issue does this PR close?
No issue in particular
- Follow-up to #10533
- Follow-up to #10552
- Related to #10458
# Rationale for this change
There are a lot of lints we can enable to, which different abilities to:
* Simplify the code
* Write more efficient code
* Catch bugs
* etc
## What changes are included in this PR?
One commit per new lint (maybe easiest to review commit by commit!).
Let me know if you disagree with any of them.
I hope to add even more lints in later PRs.
## Are these changes tested?
Covered by existing tests plus the clippy CI job.
## Are there any user-facing changes?
No.
---------
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Jeffrey Vo <[email protected]>
---
Cargo.toml | 9 ++
arrow-arith/src/aggregate.rs | 2 +-
arrow-array/src/array/fixed_size_list_array.rs | 3 +-
arrow-array/src/array/mod.rs | 2 +-
arrow-array/src/array/struct_array.rs | 2 +-
arrow-array/src/ffi.rs | 65 ++++++-------
arrow-array/src/ffi_stream.rs | 2 +-
arrow-array/src/iterator.rs | 5 +-
arrow-avro/src/codec.rs | 2 +-
.../src/reader/async_reader/async_file_reader.rs | 2 +-
arrow-avro/src/reader/mod.rs | 4 +-
arrow-avro/src/reader/record.rs | 5 +-
arrow-avro/src/schema.rs | 2 +-
arrow-avro/src/writer/encoder.rs | 2 +-
arrow-buffer/src/bigint/mod.rs | 2 +-
arrow-buffer/src/util/bit_util.rs | 2 +-
arrow-cast/src/cast/decimal.rs | 8 +-
arrow-cast/src/cast/mod.rs | 31 +++----
arrow-cast/src/cast/string.rs | 4 +-
arrow-cast/src/display.rs | 4 +-
arrow-cmp/Cargo.toml | 3 +
arrow-csv/src/writer.rs | 8 +-
arrow-data/src/equal/variable_size.rs | 4 +-
arrow-flight/src/encode.rs | 2 +-
arrow-integration-test/src/lib.rs | 2 +-
arrow-ipc/src/reader.rs | 8 +-
arrow-ipc/src/writer.rs | 12 +--
arrow-json/src/lib.rs | 2 +-
arrow-json/src/reader/schema.rs | 10 +-
arrow-json/src/reader/struct_array.rs | 3 +-
arrow-json/src/reader/tape.rs | 2 +-
arrow-json/src/writer/mod.rs | 6 +-
arrow-schema/src/datatype_parse.rs | 6 +-
arrow-schema/src/extension/canonical/bool8.rs | 2 +-
arrow-schema/src/extension/canonical/json.rs | 4 +-
.../extension/canonical/timestamp_with_offset.rs | 2 +-
arrow-schema/src/extension/canonical/uuid.rs | 2 +-
arrow-schema/src/ffi.rs | 8 +-
arrow-schema/src/field.rs | 4 +-
arrow-schema/src/schema.rs | 4 +-
arrow-select/src/coalesce.rs | 2 +-
arrow-select/src/take.rs | 2 +-
arrow-string/src/binary_like.rs | 2 +-
arrow-string/src/like.rs | 2 +-
parquet-variant-compute/src/variant_get.rs | 4 +-
parquet-variant-compute/src/variant_to_arrow.rs | 2 +-
parquet-variant-json/src/to_json.rs | 4 +-
parquet-variant/src/builder.rs | 4 +-
parquet-variant/src/builder/list.rs | 2 +-
parquet-variant/src/builder/metadata.rs | 2 +-
parquet-variant/src/builder/object.rs | 2 +-
parquet-variant/src/decoder.rs | 4 +-
parquet-variant/src/utils.rs | 2 +-
parquet/benches/metadata.rs | 6 +-
parquet/benches/row_group_index_reader.rs | 2 +-
parquet/src/arrow/arrow_reader/mod.rs | 4 +-
parquet/src/arrow/arrow_reader/statistics.rs | 2 +-
parquet/src/arrow/arrow_writer/levels.rs | 12 +--
parquet/src/arrow/arrow_writer/mod.rs | 4 +-
parquet/src/arrow/async_reader/mod.rs | 2 +-
parquet/src/arrow/schema/complex.rs | 8 +-
parquet/src/arrow/schema/mod.rs | 4 +-
parquet/src/arrow/schema/virtual_type.rs | 4 +-
parquet/src/basic.rs | 2 +-
parquet/src/column/writer/mod.rs | 4 +-
parquet/src/compression.rs | 10 +-
parquet/src/file/metadata/push_decoder.rs | 12 +--
parquet/src/file/metadata/reader.rs | 2 +-
parquet/src/file/serialized_reader.rs | 2 +-
parquet/src/geospatial/accumulator.rs | 2 +-
parquet/src/parquet_thrift.rs | 16 ++--
parquet/src/record/triplet.rs | 6 +-
parquet/src/schema/parser.rs | 101 ++++++++++-----------
parquet/src/schema/printer.rs | 2 +-
parquet/src/schema/types.rs | 2 +-
parquet/tests/encryption/encryption_async.rs | 6 +-
parquet/tests/geospatial.rs | 4 +-
77 files changed, 248 insertions(+), 257 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 39ec344fcd..535caae8d9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -166,16 +166,20 @@ default_union_representation = "warn"
disallowed_script_idents = "warn"
doc_comment_double_space_linebreaks = "warn"
doc_include_without_cfg = "warn"
+doc_link_with_quotes = "warn"
empty_enum_variants_with_brackets = "warn"
+equatable_if_let = "warn"
exit = "warn"
expl_impl_clone_on_copy = "warn"
explicit_deref_methods = "warn"
+explicit_into_iter_loop = "warn"
filter_map_next = "warn"
flat_map_option = "warn"
float_cmp_const = "warn"
fn_params_excessive_bools = "warn"
fn_to_numeric_cast_any = "warn"
format_push_string = "warn"
+ignored_unit_patterns = "warn"
imprecise_flops = "warn"
inconsistent_struct_constructor = "warn"
index_refutable_slice = "warn"
@@ -200,11 +204,14 @@ lossy_float_literal = "warn"
macro_use_imports = "warn"
manual_instant_elapsed = "warn"
manual_is_power_of_two = "warn"
+manual_is_variant_and = "warn"
manual_midpoint = "warn"
+manual_string_new = "warn"
match_wild_err_arm = "warn"
mismatching_type_param_order = "warn"
mut_mut = "warn"
mutex_integer = "warn"
+needless_raw_string_hashes = "warn"
negative_feature_names = "warn"
non_zero_suggestions = "warn"
nonstandard_macro_braces = "warn"
@@ -212,6 +219,7 @@ option_as_ref_cloned = "warn"
option_option = "warn"
path_buf_push_overwrite = "warn"
pathbuf_init_then_push = "warn"
+precedence_bits = "warn"
ptr_cast_constness = "warn"
ptr_offset_by_literal = "warn"
pub_without_shorthand = "warn"
@@ -241,6 +249,7 @@ unnecessary_literal_bound = "warn"
unnecessary_safety_doc = "warn"
unnecessary_self_imports = "warn"
unnecessary_struct_initialization = "warn"
+unnested_or_patterns = "warn"
unused_async = "warn"
unused_peekable = "warn"
unused_rounding = "warn"
diff --git a/arrow-arith/src/aggregate.rs b/arrow-arith/src/aggregate.rs
index 2e5713dd7d..3f0bf193d5 100644
--- a/arrow-arith/src/aggregate.rs
+++ b/arrow-arith/src/aggregate.rs
@@ -2005,7 +2005,7 @@ mod tests {
ItemType: Clone + Into<Option<V::Native>> + 'static,
{
let mut builder = arrow_array::builder::PrimitiveRunBuilder::<I,
V>::new();
- for v in values.into_iter() {
+ for v in values {
builder.append_option((*v).clone().into());
}
builder.finish()
diff --git a/arrow-array/src/array/fixed_size_list_array.rs
b/arrow-array/src/array/fixed_size_list_array.rs
index a6255482be..9cecc30997 100644
--- a/arrow-array/src/array/fixed_size_list_array.rs
+++ b/arrow-array/src/array/fixed_size_list_array.rs
@@ -290,8 +290,7 @@ impl FixedSizeListArray {
let nulls_valid = field.is_nullable()
|| nulls
.as_ref()
- .map(|n| n.expand(size as _).contains(&a))
- .unwrap_or_default()
+ .is_some_and(|n| n.expand(size as _).contains(&a))
|| (nulls.is_none() && a.null_count() == 0);
if !nulls_valid {
diff --git a/arrow-array/src/array/mod.rs b/arrow-array/src/array/mod.rs
index cf1e0b85a0..8a5e476846 100644
--- a/arrow-array/src/array/mod.rs
+++ b/arrow-array/src/array/mod.rs
@@ -266,7 +266,7 @@ pub unsafe trait Array: std::fmt::Debug + Send + Sync {
/// assert_eq!(array.is_null(0), false);
/// ```
fn is_null(&self, index: usize) -> bool {
- self.nulls().map(|n| n.is_null(index)).unwrap_or_default()
+ self.nulls().is_some_and(|n| n.is_null(index))
}
/// Returns whether the element at `index` is *not* null, the
diff --git a/arrow-array/src/array/struct_array.rs
b/arrow-array/src/array/struct_array.rs
index bf7dc934dc..126a3ff4b2 100644
--- a/arrow-array/src/array/struct_array.rs
+++ b/arrow-array/src/array/struct_array.rs
@@ -168,7 +168,7 @@ impl StructArray {
if !f.is_nullable()
&& let Some(a) = a.logical_nulls()
- && !nulls.as_ref().map(|n| n.contains(&a)).unwrap_or_default()
+ && nulls.as_ref().is_none_or(|n| !n.contains(&a))
&& a.null_count() > 0
{
return Err(ArrowError::InvalidArgumentError(format!(
diff --git a/arrow-array/src/ffi.rs b/arrow-array/src/ffi.rs
index 970419c633..4e132b4cc4 100644
--- a/arrow-array/src/ffi.rs
+++ b/arrow-array/src/ffi.rs
@@ -144,7 +144,7 @@ fn bit_width(data_type: &DataType, i: usize) ->
Result<usize> {
let child_bit_width = bit_width(f.data_type(), 1)?;
child_bit_width * (*num_elems as usize)
}
- (DataType::FixedSizeBinary(_), _) | (DataType::FixedSizeList(_, _), _)
=> {
+ (DataType::FixedSizeBinary(_) | DataType::FixedSizeList(_, _), _) => {
return Err(ArrowError::CDataInterface(format!(
"The datatype \"{data_type}\" expects 2 buffers, but requested
{i}. Please verify that the C data interface is correctly implemented."
)));
@@ -152,34 +152,29 @@ fn bit_width(data_type: &DataType, i: usize) ->
Result<usize> {
// Variable-size list and map have one i32 buffer.
// Variable-sized binaries: have two buffers.
// "small": first buffer is i32, second is in bytes
- (DataType::Utf8, 1)
- | (DataType::Binary, 1)
- | (DataType::List(_), 1)
- | (DataType::Map(_, _), 1) => i32::BITS as _,
- (DataType::Utf8, 2) | (DataType::Binary, 2) => u8::BITS as _,
+ (DataType::Utf8 | DataType::Binary | DataType::List(_) |
DataType::Map(_, _), 1) => {
+ i32::BITS as _
+ }
+ (DataType::Utf8 | DataType::Binary, 2) => u8::BITS as _,
// List views have two i32 buffers, offsets and sizes
- (DataType::ListView(_), 1) | (DataType::ListView(_), 2) => i32::BITS
as _,
+ (DataType::ListView(_), 1 | 2) => i32::BITS as _,
// Large list views have two i64 buffers, offsets and sizes
- (DataType::LargeListView(_), 1) | (DataType::LargeListView(_), 2) =>
i64::BITS as _,
- (DataType::List(_), _) | (DataType::Map(_, _), _) => {
+ (DataType::LargeListView(_), 1 | 2) => i64::BITS as _,
+ (DataType::List(_) | DataType::Map(_, _), _) => {
return Err(ArrowError::CDataInterface(format!(
"The datatype \"{data_type}\" expects 2 buffers, but requested
{i}. Please verify that the C data interface is correctly implemented."
)));
}
- (DataType::Utf8, _) | (DataType::Binary, _) => {
+ (DataType::Utf8 | DataType::Binary, _) => {
return Err(ArrowError::CDataInterface(format!(
"The datatype \"{data_type}\" expects 3 buffers, but requested
{i}. Please verify that the C data interface is correctly implemented."
)));
}
// Variable-sized binaries: have two buffers.
// LargeUtf8: first buffer is i64, second is in bytes
- (DataType::LargeUtf8, 1) | (DataType::LargeBinary, 1) |
(DataType::LargeList(_), 1) => {
- i64::BITS as _
- }
- (DataType::LargeUtf8, 2) | (DataType::LargeBinary, 2) |
(DataType::LargeList(_), 2) => {
- u8::BITS as _
- }
- (DataType::LargeUtf8, _) | (DataType::LargeBinary, _) |
(DataType::LargeList(_), _) => {
+ (DataType::LargeUtf8 | DataType::LargeBinary | DataType::LargeList(_),
1) => i64::BITS as _,
+ (DataType::LargeUtf8 | DataType::LargeBinary | DataType::LargeList(_),
2) => u8::BITS as _,
+ (DataType::LargeUtf8 | DataType::LargeBinary | DataType::LargeList(_),
_) => {
return Err(ArrowError::CDataInterface(format!(
"The datatype \"{data_type}\" expects 3 buffers, but requested
{i}. Please verify that the C data interface is correctly implemented."
)));
@@ -187,8 +182,8 @@ fn bit_width(data_type: &DataType, i: usize) ->
Result<usize> {
// Variable-sized views: have 3 or more buffers.
// Buffer 1 are the u128 views
// Buffers 2...N-1 are u8 byte buffers
- (DataType::Utf8View, 1) | (DataType::BinaryView, 1) => u128::BITS as _,
- (DataType::Utf8View, _) | (DataType::BinaryView, _) => u8::BITS as _,
+ (DataType::Utf8View | DataType::BinaryView, 1) => u128::BITS as _,
+ (DataType::Utf8View | DataType::BinaryView, _) => u8::BITS as _,
// type ids. UnionArray doesn't have null bitmap so buffer index
begins with 0.
(DataType::Union(_, _), 0) => i8::BITS as _,
// Only DenseUnion has 2nd buffer
@@ -456,27 +451,27 @@ impl ImportedArrowArray<'_> {
// Inner type is not important for buffer length.
Ok(match (&data_type, i) {
- (DataType::Utf8, 1)
- | (DataType::LargeUtf8, 1)
- | (DataType::Binary, 1)
- | (DataType::LargeBinary, 1)
- | (DataType::List(_), 1)
- | (DataType::LargeList(_), 1)
- | (DataType::Map(_, _), 1) => {
+ (
+ DataType::Utf8
+ | DataType::LargeUtf8
+ | DataType::Binary
+ | DataType::LargeBinary
+ | DataType::List(_)
+ | DataType::LargeList(_)
+ | DataType::Map(_, _),
+ 1,
+ ) => {
// the len of the offset buffer (buffer 1) equals length + 1
let bits = bit_width(data_type, i)?;
debug_assert_eq!(bits % 8, 0);
(length + 1) * (bits / 8)
}
- (DataType::ListView(_), 1)
- | (DataType::ListView(_), 2)
- | (DataType::LargeListView(_), 1)
- | (DataType::LargeListView(_), 2) => {
+ (DataType::ListView(_) | DataType::LargeListView(_), 1 | 2) => {
let bits = bit_width(data_type, i)?;
debug_assert_eq!(bits % 8, 0);
length * (bits / 8)
}
- (DataType::Utf8, 2) | (DataType::Binary, 2) => {
+ (DataType::Utf8 | DataType::Binary, 2) => {
if self.array.is_empty() {
return Ok(0);
}
@@ -490,7 +485,7 @@ impl ImportedArrowArray<'_> {
// get last offset
(unsafe { *offset_buffer.add(len / size_of::<i32>() - 1) }) as
usize
}
- (DataType::LargeUtf8, 2) | (DataType::LargeBinary, 2) => {
+ (DataType::LargeUtf8 | DataType::LargeBinary, 2) => {
if self.array.is_empty() {
return Ok(0);
}
@@ -508,10 +503,8 @@ impl ImportedArrowArray<'_> {
// Buffer 1 is the views buffer, which stores 1 u128 per length of
the array.
// Buffers 2..N-1 are the buffers holding the byte data. Their
lengths are variable.
// Buffer N is of length (N - 2) and stores i64 containing the
lengths of buffers 2..N-1
- (DataType::Utf8View, 1) | (DataType::BinaryView, 1) => {
- std::mem::size_of::<u128>() * length
- }
- (DataType::Utf8View, i) | (DataType::BinaryView, i) => {
+ (DataType::Utf8View | DataType::BinaryView, 1) =>
std::mem::size_of::<u128>() * length,
+ (DataType::Utf8View | DataType::BinaryView, i) => {
variadic_buffer_lengths[i - 2] as usize
}
// buffer len of primitive types
diff --git a/arrow-array/src/ffi_stream.rs b/arrow-array/src/ffi_stream.rs
index 011f3a8b0f..f307416bbf 100644
--- a/arrow-array/src/ffi_stream.rs
+++ b/arrow-array/src/ffi_stream.rs
@@ -544,7 +544,7 @@ mod tests {
fn test_error_import() -> Result<()> {
let schema = Arc::new(Schema::new(vec![Field::new("a",
DataType::Int32, true)]));
- let iter =
Box::new(vec![Err(ArrowError::MemoryError("".to_string()))].into_iter());
+ let iter =
Box::new(vec![Err(ArrowError::MemoryError(String::new()))].into_iter());
let reader = Box::new(TestRecordBatchReader::new(schema.clone(),
iter));
diff --git a/arrow-array/src/iterator.rs b/arrow-array/src/iterator.rs
index 156e296cf1..d954c9ce2f 100644
--- a/arrow-array/src/iterator.rs
+++ b/arrow-array/src/iterator.rs
@@ -67,10 +67,7 @@ impl<T: ArrayAccessor> ArrayIter<T> {
#[inline]
fn is_null(&self, idx: usize) -> bool {
- self.logical_nulls
- .as_ref()
- .map(|x| x.is_null(idx))
- .unwrap_or_default()
+ self.logical_nulls.as_ref().is_some_and(|x| x.is_null(idx))
}
}
diff --git a/arrow-avro/src/codec.rs b/arrow-avro/src/codec.rs
index 5618539c50..ec6224ed1e 100644
--- a/arrow-avro/src/codec.rs
+++ b/arrow-avro/src/codec.rs
@@ -600,7 +600,7 @@ impl AvroField {
/// converted to use `Utf8View` instead of `Utf8`.
pub(crate) fn with_utf8view(&self) -> Self {
let mut field = self.clone();
- if let Codec::Utf8 = field.data_type.codec {
+ if field.data_type.codec == Codec::Utf8 {
field.data_type.codec = Codec::Utf8View;
}
field
diff --git a/arrow-avro/src/reader/async_reader/async_file_reader.rs
b/arrow-avro/src/reader/async_reader/async_file_reader.rs
index e7f567bcd8..0e6af9fba3 100644
--- a/arrow-avro/src/reader/async_reader/async_file_reader.rs
+++ b/arrow-avro/src/reader/async_reader/async_file_reader.rs
@@ -96,7 +96,7 @@ pub trait AsyncFileReader: Send {
async move {
let mut result = Vec::with_capacity(ranges.len());
- for range in ranges.into_iter() {
+ for range in ranges {
let data = self.get_bytes(range).await?;
result.push(data);
}
diff --git a/arrow-avro/src/reader/mod.rs b/arrow-avro/src/reader/mod.rs
index 505d140831..6568a37577 100644
--- a/arrow-avro/src/reader/mod.rs
+++ b/arrow-avro/src/reader/mod.rs
@@ -4774,8 +4774,8 @@ mod test {
{
let idx = schema.index_of("array_of_union").unwrap();
let dt = schema.field(idx).data_type().clone();
- let (item_field, _) = match &dt {
- DataType::List(f) => (f.clone(), ()),
+ let item_field = match &dt {
+ DataType::List(f) => f.clone(),
other => panic!("array_of_union must be List, got {other:?}"),
};
let (uf, _) = match item_field.data_type() {
diff --git a/arrow-avro/src/reader/record.rs b/arrow-avro/src/reader/record.rs
index beb4102de1..9f97a800a0 100644
--- a/arrow-avro/src/reader/record.rs
+++ b/arrow-avro/src/reader/record.rs
@@ -324,8 +324,7 @@ impl Decoder {
(Codec::Float64, Some(Promotion::FloatToDouble)) => {
Self::Float32ToFloat64(Vec::with_capacity(DEFAULT_CAPACITY))
}
- (Codec::Utf8, Some(Promotion::BytesToString))
- | (Codec::Utf8View, Some(Promotion::BytesToString)) =>
Self::BytesToString(
+ (Codec::Utf8 | Codec::Utf8View, Some(Promotion::BytesToString)) =>
Self::BytesToString(
OffsetBufferBuilder::new(DEFAULT_CAPACITY),
Vec::with_capacity(DEFAULT_CAPACITY),
),
@@ -4430,7 +4429,7 @@ mod tests {
) -> AvroDataType {
let mut avro_children: Vec<AvroDataType> =
Vec::with_capacity(children.len());
let mut fields: Vec<arrow_schema::Field> =
Vec::with_capacity(children.len());
- for (codec, name, dt) in children.into_iter() {
+ for (codec, name, dt) in children {
avro_children.push(AvroDataType::new(codec, Default::default(),
None));
fields.push(arrow_schema::Field::new(name, dt, true));
}
diff --git a/arrow-avro/src/schema.rs b/arrow-avro/src/schema.rs
index a22373ac6c..b95158e1aa 100644
--- a/arrow-avro/src/schema.rs
+++ b/arrow-avro/src/schema.rs
@@ -177,7 +177,7 @@ pub(crate) enum Schema<'a> {
/// A direct type name (primitive or reference)
#[serde(borrow)]
TypeName(TypeName<'a>),
- /// A union of multiple schemas (e.g., ["null", "string"])
+ /// A union of multiple schemas (e.g., `["null", "string"]`)
#[serde(borrow)]
Union(Vec<Schema<'a>>),
/// A complex type such as record, array, map, etc.
diff --git a/arrow-avro/src/writer/encoder.rs b/arrow-avro/src/writer/encoder.rs
index e88337cd6d..4d1140677c 100644
--- a/arrow-avro/src/writer/encoder.rs
+++ b/arrow-avro/src/writer/encoder.rs
@@ -1044,7 +1044,7 @@ impl FieldPlan {
{
matches!(
arrow_field.extension_type_name(),
- Some("arrow.uuid") | Some("uuid")
+ Some("arrow.uuid" | "uuid")
)
}
#[cfg(not(feature = "canonical_extension_types"))]
diff --git a/arrow-buffer/src/bigint/mod.rs b/arrow-buffer/src/bigint/mod.rs
index d8328cb06f..e9db73ece3 100644
--- a/arrow-buffer/src/bigint/mod.rs
+++ b/arrow-buffer/src/bigint/mod.rs
@@ -1478,7 +1478,7 @@ mod tests {
}
// Exponentiation
- for exp in vec![0, 1, 2, 3, 8, 100].into_iter() {
+ for exp in [0, 1, 2, 3, 8, 100] {
let actual = il.wrapping_pow(exp);
let (expected, overflow) =
i256::from_bigint_with_overflow(bl.clone().pow(exp));
assert_eq!(actual.to_string(), expected.to_string());
diff --git a/arrow-buffer/src/util/bit_util.rs
b/arrow-buffer/src/util/bit_util.rs
index fbe064233d..6fe4acb839 100644
--- a/arrow-buffer/src/util/bit_util.rs
+++ b/arrow-buffer/src/util/bit_util.rs
@@ -809,7 +809,7 @@ fn get_remainder_bits(remainder: &[u8], remainder_len:
usize) -> u64 {
.iter()
.enumerate()
.fold(0_u64, |acc, (index, &byte)| {
- acc | (byte as u64) << (index * 8)
+ acc | ((byte as u64) << (index * 8))
});
bits & ((1 << remainder_len) - 1)
diff --git a/arrow-cast/src/cast/decimal.rs b/arrow-cast/src/cast/decimal.rs
index 9d1465567e..a6497332d7 100644
--- a/arrow-cast/src/cast/decimal.rs
+++ b/arrow-cast/src/cast/decimal.rs
@@ -370,7 +370,7 @@ where
let error = cast_decimal_to_decimal_error::<I, O>(output_precision,
output_scale);
array.try_unary(|x| {
f_fallible(x).ok_or_else(|| error(x)).and_then(|v| {
- O::validate_decimal_precision(v, output_precision,
output_scale).map(|_| v)
+ O::validate_decimal_precision(v, output_precision,
output_scale).map(|()| v)
})
})?
};
@@ -671,7 +671,9 @@ where
T::DATA_TYPE,
))
})
- .and_then(|v| T::validate_decimal_precision(v,
precision, scale).map(|_| v))
+ .and_then(|v| {
+ T::validate_decimal_precision(v, precision,
scale).map(|()| v)
+ })
})
.transpose()
})
@@ -801,7 +803,7 @@ where
v
))
})
- .and_then(|v| D::validate_decimal_precision(v, precision,
scale).map(|_| v))
+ .and_then(|v| D::validate_decimal_precision(v, precision,
scale).map(|()| v))
})?
.with_precision_and_scale(precision, scale)
.map(|a| Arc::new(a) as ArrayRef)
diff --git a/arrow-cast/src/cast/mod.rs b/arrow-cast/src/cast/mod.rs
index 50357a5f94..758d68fa2d 100644
--- a/arrow-cast/src/cast/mod.rs
+++ b/arrow-cast/src/cast/mod.rs
@@ -269,14 +269,9 @@ pub fn can_cast_types(from_type: &DataType, to_type:
&DataType) -> bool {
| LargeUtf8
| Date32
| Date64
- | Time32(Second)
- | Time32(Millisecond)
- | Time64(Microsecond)
- | Time64(Nanosecond)
- | Timestamp(Second, _)
- | Timestamp(Millisecond, _)
- | Timestamp(Microsecond, _)
- | Timestamp(Nanosecond, _)
+ | Time32(Second | Millisecond)
+ | Time64(Microsecond | Nanosecond)
+ | Timestamp(Second | Millisecond | Microsecond | Nanosecond, _)
| Interval(_)
| BinaryView,
) => true,
@@ -320,10 +315,8 @@ pub fn can_cast_types(from_type: &DataType, to_type:
&DataType) -> bool {
Timestamp(_, _)
| Date32
| Date64
- | Time32(Second)
- | Time32(Millisecond)
- | Time64(Microsecond)
- | Time64(Nanosecond),
+ | Time32(Second | Millisecond)
+ | Time64(Microsecond | Nanosecond),
) => true,
(_, Duration(_)) if from_type.is_numeric() => true,
(Duration(_), _) if to_type.is_numeric() => true,
@@ -390,7 +383,7 @@ where
false => array.try_unary::<_, D, _>(|v| {
v.as_()
.div_checked(scale_factor)
- .and_then(|v| D::validate_decimal_precision(v, precision,
scale).map(|_| v))
+ .and_then(|v| D::validate_decimal_precision(v, precision,
scale).map(|()| v))
})?,
}
} else {
@@ -404,7 +397,7 @@ where
false => array.try_unary::<_, D, _>(|v| {
v.as_()
.mul_checked(scale_factor)
- .and_then(|v| D::validate_decimal_precision(v, precision,
scale).map(|_| v))
+ .and_then(|v| D::validate_decimal_precision(v, precision,
scale).map(|()| v))
})?,
}
};
@@ -2704,7 +2697,7 @@ fn cast_binary_to_fixed_size_binary<O: OffsetSizeTrait>(
builder.append_null();
} else {
match builder.append_value(array.value(i)) {
- Ok(_) => {}
+ Ok(()) => {}
Err(e) => match cast_options.safe {
true => builder.append_null(),
false => return Err(e),
@@ -5871,12 +5864,12 @@ mod tests {
test_unsafe_string_to_interval_err!(
vec![Some("2 months 31 days 1 second")],
IntervalUnit::YearMonth,
- r#"Cast error: Cannot cast 2 months 31 days 1 second to
IntervalYearMonth. Only year and month fields are allowed."#
+ "Cast error: Cannot cast 2 months 31 days 1 second to
IntervalYearMonth. Only year and month fields are allowed."
);
test_unsafe_string_to_interval_err!(
vec![Some("1 day 1.5 milliseconds")],
IntervalUnit::DayTime,
- r#"Cast error: Cannot cast 1 day 1.5 milliseconds to
IntervalDayTime because the nanos part isn't multiple of milliseconds"#
+ "Cast error: Cannot cast 1 day 1.5 milliseconds to IntervalDayTime
because the nanos part isn't multiple of milliseconds"
);
// overflow
@@ -7618,7 +7611,7 @@ mod tests {
let string_view_array = {
let mut builder =
StringViewBuilder::new().with_fixed_block_size(8); // multiple buffers.
- for v in typed_dict.into_iter() {
+ for v in typed_dict {
builder.append_option(v);
}
builder.finish()
@@ -7635,7 +7628,7 @@ mod tests {
let binary_view_array = {
let mut builder =
BinaryViewBuilder::new().with_fixed_block_size(8); // multiple buffers.
- for v in typed_binary_dict.into_iter() {
+ for v in typed_binary_dict {
builder.append_option(v);
}
builder.finish()
diff --git a/arrow-cast/src/cast/string.rs b/arrow-cast/src/cast/string.rs
index 86712e15f9..3c19335196 100644
--- a/arrow-cast/src/cast/string.rs
+++ b/arrow-cast/src/cast/string.rs
@@ -26,7 +26,7 @@ pub(crate) fn value_to_string<O: OffsetSizeTrait>(
let formatter = ArrayFormatter::try_new(array, &options.format_options)?;
let nulls = array.nulls();
for i in 0..array.len() {
- match nulls.map(|x| x.is_null(i)).unwrap_or_default() {
+ match nulls.is_some_and(|x| x.is_null(i)) {
true => builder.append_null(),
false => {
formatter.value(i).write(&mut builder)?;
@@ -49,7 +49,7 @@ pub(crate) fn value_to_string_view(
// TODO: replace with write to builder after
https://github.com/apache/arrow-rs/issues/6373
let mut buffer = String::new();
for i in 0..array.len() {
- match nulls.map(|x| x.is_null(i)).unwrap_or_default() {
+ match nulls.is_some_and(|x| x.is_null(i)) {
true => builder.append_null(),
false => {
// write to buffer first and then copy into target array
diff --git a/arrow-cast/src/display.rs b/arrow-cast/src/display.rs
index bacaef46d7..5705a455c9 100644
--- a/arrow-cast/src/display.rs
+++ b/arrow-cast/src/display.rs
@@ -419,7 +419,7 @@ impl ValueFormatter<'_> {
/// will return an error on formatting issue
pub fn write(&self, s: &mut dyn Write) -> Result<(), ArrowError> {
match self.formatter.format.write(self.idx, s) {
- Ok(_) => Ok(()),
+ Ok(()) => Ok(()),
Err(FormatError::Arrow(e)) => Err(e),
Err(FormatError::Format(_)) => Err(ArrowError::CastError("Format
error".to_string())),
}
@@ -614,7 +614,7 @@ impl<'a, T: DisplayIndex> DisplayIndexState<'a> for T {
Ok(())
}
- fn write(&self, _: &Self::State, idx: usize, f: &mut dyn Write) ->
FormatResult {
+ fn write(&self, (): &Self::State, idx: usize, f: &mut dyn Write) ->
FormatResult {
DisplayIndex::write(self, idx, f)
}
}
diff --git a/arrow-cmp/Cargo.toml b/arrow-cmp/Cargo.toml
index bbeadb22ab..5a66ab3419 100644
--- a/arrow-cmp/Cargo.toml
+++ b/arrow-cmp/Cargo.toml
@@ -42,3 +42,6 @@ arrow-schema = { workspace = true }
[dev-dependencies]
half = { version = "2.1", default-features = false, features = ["num-traits"] }
+
+[lints]
+workspace = true
diff --git a/arrow-csv/src/writer.rs b/arrow-csv/src/writer.rs
index 5236775b68..af413c889d 100644
--- a/arrow-csv/src/writer.rs
+++ b/arrow-csv/src/writer.rs
@@ -739,14 +739,14 @@ mod tests {
let mut buffer: Vec<u8> = vec![];
file.read_to_end(&mut buffer).unwrap();
- let expected = r#"c1,c2,c3,c4,c5,c6,c7
+ let expected = r"c1,c2,c3,c4,c5,c6,c7
Lorem ipsum dolor sit amet,123.564532,3,true,,00:20:34,cupcakes
consectetur adipiscing elit,,2,false,2019-04-18T10:54:47.378,06:51:20,cupcakes
sed do eiusmod tempor,-556132.25,1,,2019-04-18T02:45:55.555,23:46:03,foo
Lorem ipsum dolor sit amet,123.564532,3,true,,00:20:34,cupcakes
consectetur adipiscing elit,,2,false,2019-04-18T10:54:47.378,06:51:20,cupcakes
sed do eiusmod tempor,-556132.25,1,,2019-04-18T02:45:55.555,23:46:03,foo
-"#;
+";
assert_eq!(expected, str::from_utf8(&buffer).unwrap());
}
@@ -800,7 +800,7 @@ sed do eiusmod
tempor,-556132.25,1,,2019-04-18T02:45:55.555,23:46:03,foo
let mut buffer: Vec<u8> = vec![];
file.read_to_end(&mut buffer).unwrap();
- let expected = r#"c1,c2,c3,c4
+ let expected = r"c1,c2,c3,c4
-3.335724,-3.335724,-3.335724,-3.335724
2.179404,2.179404,2.179404,2.179404
,,,
@@ -809,7 +809,7 @@ sed do eiusmod
tempor,-556132.25,1,,2019-04-18T02:45:55.555,23:46:03,foo
2.179404,2.179404,2.179404,2.179404
,,,
0.290472,0.290472,0.290472,0.290472
-"#;
+";
assert_eq!(expected, str::from_utf8(&buffer).unwrap());
}
diff --git a/arrow-data/src/equal/variable_size.rs
b/arrow-data/src/equal/variable_size.rs
index 10aeafd7e9..d80faaf2ca 100644
--- a/arrow-data/src/equal/variable_size.rs
+++ b/arrow-data/src/equal/variable_size.rs
@@ -81,8 +81,8 @@ pub(super) fn variable_sized_equal<T: ArrowNativeType +
Integer>(
let rhs_pos = rhs_start + i;
// the null bits can still be `None`, indicating that the value is
valid.
- let lhs_is_null = lhs.nulls().map(|v|
v.is_null(lhs_pos)).unwrap_or_default();
- let rhs_is_null = rhs.nulls().map(|v|
v.is_null(rhs_pos)).unwrap_or_default();
+ let lhs_is_null = lhs.nulls().is_some_and(|v| v.is_null(lhs_pos));
+ let rhs_is_null = rhs.nulls().is_some_and(|v| v.is_null(rhs_pos));
lhs_is_null
|| (lhs_is_null == rhs_is_null)
diff --git a/arrow-flight/src/encode.rs b/arrow-flight/src/encode.rs
index 95fde96e37..437d910deb 100644
--- a/arrow-flight/src/encode.rs
+++ b/arrow-flight/src/encode.rs
@@ -442,7 +442,7 @@ impl Stream for FlightDataEncoder {
/// [`DictionaryArray`]: arrow_array::DictionaryArray
///
/// In the arrow flight protocol dictionary values and keys are sent as two
separate messages.
-/// When a sender is encoding a [`RecordBatch`] containing ['DictionaryArray']
columns, it will
+/// When a sender is encoding a [`RecordBatch`] containing [`DictionaryArray`]
columns, it will
/// first send a dictionary batch (a batch with header
`MessageHeader::DictionaryBatch`) containing
/// the dictionary values. The receiver is responsible for reading this batch
and maintaining state that associates
/// those dictionary values with the corresponding array using the `dict_id`
as a key.
diff --git a/arrow-integration-test/src/lib.rs
b/arrow-integration-test/src/lib.rs
index 0d5477e955..a752aed7d8 100644
--- a/arrow-integration-test/src/lib.rs
+++ b/arrow-integration-test/src/lib.rs
@@ -223,7 +223,7 @@ impl ArrowJson {
return Ok(false);
}
- for json_batch in self.get_record_batches()?.into_iter() {
+ for json_batch in self.get_record_batches()? {
let batch = reader.next();
match batch {
Some(Ok(batch)) => {
diff --git a/arrow-ipc/src/reader.rs b/arrow-ipc/src/reader.rs
index c25e40f2bc..39cdb731bb 100644
--- a/arrow-ipc/src/reader.rs
+++ b/arrow-ipc/src/reader.rs
@@ -1260,7 +1260,7 @@ impl FileReaderBuilder {
let mut custom_metadata = HashMap::new();
if let Some(fb_custom_metadata) = footer.custom_metadata() {
- for kv in fb_custom_metadata.into_iter() {
+ for kv in fb_custom_metadata {
custom_metadata.insert(
kv.key().unwrap().to_string(),
kv.value().unwrap().to_string(),
@@ -1386,7 +1386,7 @@ impl<R: Read + Seek> FileReader<R> {
///
/// # Errors
///
- /// An ['Err'](Result::Err) may be returned if:
+ /// An [`Err`] may be returned if:
/// - the file does not meet the Arrow Format footer requirements, or
/// - file endianness does not match the target endianness.
pub fn try_new(reader: R, projection: Option<Vec<usize>>) -> Result<Self,
ArrowError> {
@@ -1570,7 +1570,7 @@ impl<R: Read> StreamReader<R> {
///
/// # Errors
///
- /// An ['Err'](Result::Err) may be returned if the reader does not
encounter a schema
+ /// An [`Err`] may be returned if the reader does not encounter a schema
/// as the first message in the stream.
pub fn try_new(
reader: R,
@@ -1861,7 +1861,7 @@ impl<R: Read> MessageReader<R> {
pub fn read_meta_len(&mut self) -> Result<Option<usize>, ArrowError> {
let mut meta_len: [u8; 4] = [0; 4];
match self.reader.read_exact(&mut meta_len) {
- Ok(_) => {}
+ Ok(()) => {}
Err(e) => {
return if e.kind() == std::io::ErrorKind::UnexpectedEof {
// Handle EOF without the "0xFFFFFFFF 0x00000000"
diff --git a/arrow-ipc/src/writer.rs b/arrow-ipc/src/writer.rs
index de89f423ab..20d3441a3f 100644
--- a/arrow-ipc/src/writer.rs
+++ b/arrow-ipc/src/writer.rs
@@ -1631,7 +1631,7 @@ impl<W: Write> FileWriter<W> {
///
/// # Errors
///
- /// An ['Err'](Result::Err) may be returned if writing the header to the
writer fails.
+ /// An [`Err`] may be returned if writing the header to the writer fails.
pub fn try_new(writer: W, schema: &Schema) -> Result<Self, ArrowError> {
let write_options = IpcWriteOptions::default();
Self::try_new_with_options(writer, schema, write_options)
@@ -1643,7 +1643,7 @@ impl<W: Write> FileWriter<W> {
///
/// # Errors
///
- /// An ['Err'](Result::Err) may be returned if writing the header to the
writer fails.
+ /// An [`Err`] may be returned if writing the header to the writer fails.
pub fn try_new_with_options(
mut writer: W,
schema: &Schema,
@@ -1801,7 +1801,7 @@ impl<W: Write> FileWriter<W> {
///
/// # Errors
///
- /// An ['Err'](Result::Err) may be returned if an error occurs while
finishing the StreamWriter
+ /// An [`Err`] may be returned if an error occurs while finishing the
StreamWriter
/// or while flushing the writer.
pub fn into_inner(mut self) -> Result<W, ArrowError> {
if !self.finished {
@@ -2043,7 +2043,7 @@ impl<W: Write> StreamWriter<W> {
///
/// # Errors
///
- /// An ['Err'](Result::Err) may be returned if writing the header to the
writer fails.
+ /// An [`Err`] may be returned if writing the header to the writer fails.
pub fn try_new(writer: W, schema: &Schema) -> Result<Self, ArrowError> {
let write_options = IpcWriteOptions::default();
Self::try_new_with_options(writer, schema, write_options)
@@ -2053,7 +2053,7 @@ impl<W: Write> StreamWriter<W> {
///
/// # Errors
///
- /// An ['Err'](Result::Err) may be returned if writing the header to the
writer fails.
+ /// An [`Err`] may be returned if writing the header to the writer fails.
pub fn try_new_with_options(
mut writer: W,
schema: &Schema,
@@ -2143,7 +2143,7 @@ impl<W: Write> StreamWriter<W> {
///
/// # Errors
///
- /// An ['Err'](Result::Err) may be returned if an error occurs while
finishing the StreamWriter
+ /// An [`Err`] may be returned if an error occurs while finishing the
StreamWriter
/// or while flushing the writer.
///
/// # Example
diff --git a/arrow-json/src/lib.rs b/arrow-json/src/lib.rs
index 9f2a9e3a81..bc7cc66801 100644
--- a/arrow-json/src/lib.rs
+++ b/arrow-json/src/lib.rs
@@ -101,7 +101,7 @@ use serde_json::{Number, Value};
/// Writer will produce. For example, if the RecordBatch Schema is
/// `[("a", Int32), ("r", Struct("b": Boolean, "c" Utf8))]`
/// then a Reader with [`StructMode::ObjectOnly`] would read rows of the form
-/// `{"a": 1, "r": {"b": true, "c": "cat"}}` while with
['StructMode::ListOnly']
+/// `{"a": 1, "r": {"b": true, "c": "cat"}}` while with
[`StructMode::ListOnly`]
/// would read rows of the form `[1, [true, "cat"]]`. A Writer would produce
/// rows formatted similarly.
///
diff --git a/arrow-json/src/reader/schema.rs b/arrow-json/src/reader/schema.rs
index 524e6b2aa5..f9f70da1f0 100644
--- a/arrow-json/src/reader/schema.rs
+++ b/arrow-json/src/reader/schema.rs
@@ -94,9 +94,8 @@ fn coerce_data_type(dt: Vec<&DataType>) -> DataType {
(DataType::Null, o) | (o, DataType::Null) => o,
(DataType::Boolean, DataType::Boolean) => DataType::Boolean,
(DataType::Int64, DataType::Int64) => DataType::Int64,
- (DataType::Float64, DataType::Float64)
- | (DataType::Float64, DataType::Int64)
- | (DataType::Int64, DataType::Float64) => DataType::Float64,
+ (DataType::Float64 | DataType::Int64, DataType::Float64)
+ | (DataType::Float64, DataType::Int64) => DataType::Float64,
(DataType::List(l), DataType::List(r)) => {
list_type_of(coerce_data_type(vec![l.data_type(), r.data_type()]))
}
@@ -388,7 +387,10 @@ fn collect_field_types_from_object(
set_object_scalar_field_type(field_types, k, DataType::Utf8)?;
}
Value::Object(inner_map) => {
- if let InferredType::Any =
field_types.get(k).unwrap_or(&InferredType::Any) {
+ if matches!(
+ field_types.get(k).unwrap_or(&InferredType::Any),
+ InferredType::Any
+ ) {
field_types.insert(k.to_string(),
InferredType::Object(HashMap::new()));
}
match field_types.get_mut(k).unwrap() {
diff --git a/arrow-json/src/reader/struct_array.rs
b/arrow-json/src/reader/struct_array.rs
index d310618e10..75bb02781b 100644
--- a/arrow-json/src/reader/struct_array.rs
+++ b/arrow-json/src/reader/struct_array.rs
@@ -248,8 +248,7 @@ impl ArrayDecoder for StructArrayDecoder {
// Sanity check
assert_eq!(c.len(), pos.len());
if let Some(a) = c.nulls() {
- let nulls_valid =
- f.is_nullable() || nulls.as_ref().map(|n|
n.contains(a)).unwrap_or_default();
+ let nulls_valid = f.is_nullable() ||
nulls.as_ref().is_some_and(|n| n.contains(a));
if !nulls_valid {
return Err(ArrowError::JsonError(format!(
diff --git a/arrow-json/src/reader/tape.rs b/arrow-json/src/reader/tape.rs
index 683e172d5d..32f40024bf 100644
--- a/arrow-json/src/reader/tape.rs
+++ b/arrow-json/src/reader/tape.rs
@@ -413,7 +413,7 @@ impl TapeDecoder {
iter.skip_whitespace();
*state = match next!(iter) {
b'"' => DecoderState::String,
- b @ b'-' | b @ b'0'..=b'9' => {
+ b @ (b'-' | b'0'..=b'9') => {
self.bytes.push(b);
DecoderState::Number
}
diff --git a/arrow-json/src/writer/mod.rs b/arrow-json/src/writer/mod.rs
index 60a7c9469d..3596d41883 100644
--- a/arrow-json/src/writer/mod.rs
+++ b/arrow-json/src/writer/mod.rs
@@ -2604,11 +2604,7 @@ mod tests {
// 1. You can use information from Field to determine how to
do the encoding.
// 2. For dictionary arrays the Field is always the outer
field but the array may be the keys or values array
// and thus the data type of `field` may not match the data
type of `array`.
- let padded = field
- .metadata()
- .get("padded")
- .map(|v| v == "true")
- .unwrap_or_default();
+ let padded = field.metadata().get("padded").is_some_and(|v| v
== "true");
match (array.data_type(), padded) {
(DataType::Int32, true) => {
let array = array.as_primitive::<Int32Type>();
diff --git a/arrow-schema/src/datatype_parse.rs
b/arrow-schema/src/datatype_parse.rs
index cc4dbf44ad..9439d8ea21 100644
--- a/arrow-schema/src/datatype_parse.rs
+++ b/arrow-schema/src/datatype_parse.rs
@@ -1429,7 +1429,7 @@ mod test {
),
])),
),
- (r#"Struct()"#, Struct(Fields::empty())),
+ (r"Struct()", Struct(Fields::empty())),
(
"FixedSizeList(4, Int64)",
FixedSizeList(Arc::new(Field::new_list_field(Int64, true)), 4),
@@ -1461,12 +1461,12 @@ mod test {
("", "Error finding next token"),
("null", "Unsupported type 'null'"),
("Nu", "Unsupported type 'Nu'"),
- (r#"Timestamp(ns, +00:00)"#, "Error unknown token: +00"),
+ (r"Timestamp(ns, +00:00)", "Error unknown token: +00"),
(
r#"Timestamp(ns, "+00:00)"#,
r#"Unterminated string at: "+00:00)"#,
),
- (r#"Timestamp(ns, "")"#, r#"empty strings aren't allowed"#),
+ (r#"Timestamp(ns, "")"#, r"empty strings aren't allowed"),
(
r#"Timestamp(ns, "+00:00"")"#,
r#"Parser error: Unterminated string at: ")"#,
diff --git a/arrow-schema/src/extension/canonical/bool8.rs
b/arrow-schema/src/extension/canonical/bool8.rs
index 17eeb240ac..75df61a632 100644
--- a/arrow-schema/src/extension/canonical/bool8.rs
+++ b/arrow-schema/src/extension/canonical/bool8.rs
@@ -66,7 +66,7 @@ impl ExtensionType for Bool8 {
}
fn try_new(data_type: &DataType, _metadata: Self::Metadata) ->
Result<Self, ArrowError> {
- Self.supports_data_type(data_type).map(|_| Self)
+ Self.supports_data_type(data_type).map(|()| Self)
}
fn validate(data_type: &DataType, _metadata: Self::Metadata) -> Result<(),
ArrowError> {
diff --git a/arrow-schema/src/extension/canonical/json.rs
b/arrow-schema/src/extension/canonical/json.rs
index 1188a6dda4..59f226bd80 100644
--- a/arrow-schema/src/extension/canonical/json.rs
+++ b/arrow-schema/src/extension/canonical/json.rs
@@ -137,7 +137,7 @@ impl ExtensionType for Json {
.as_ref()
.map(serde_json::to_string)
.map(Result::unwrap)
- .unwrap_or_else(|| "".to_owned()),
+ .unwrap_or_default(),
)
}
@@ -196,7 +196,7 @@ mod tests {
field.try_with_extension_type(Json::default())?;
assert_eq!(
field.metadata().get(EXTENSION_TYPE_METADATA_KEY),
- Some(&"".to_owned())
+ Some(&String::new())
);
assert_eq!(
field.try_extension_type::<Json>()?,
diff --git a/arrow-schema/src/extension/canonical/timestamp_with_offset.rs
b/arrow-schema/src/extension/canonical/timestamp_with_offset.rs
index 84b49564ae..e40a21ad63 100644
--- a/arrow-schema/src/extension/canonical/timestamp_with_offset.rs
+++ b/arrow-schema/src/extension/canonical/timestamp_with_offset.rs
@@ -137,7 +137,7 @@ impl ExtensionType for TimestampWithOffset {
}
fn try_new(data_type: &DataType, _metadata: Self::Metadata) ->
Result<Self, ArrowError> {
- Self.supports_data_type(data_type).map(|_| Self)
+ Self.supports_data_type(data_type).map(|()| Self)
}
fn validate(data_type: &DataType, _metadata: Self::Metadata) -> Result<(),
ArrowError> {
diff --git a/arrow-schema/src/extension/canonical/uuid.rs
b/arrow-schema/src/extension/canonical/uuid.rs
index 16e7de4380..345fe0397b 100644
--- a/arrow-schema/src/extension/canonical/uuid.rs
+++ b/arrow-schema/src/extension/canonical/uuid.rs
@@ -75,7 +75,7 @@ impl ExtensionType for Uuid {
}
fn try_new(data_type: &DataType, _metadata: Self::Metadata) ->
Result<Self, ArrowError> {
- Self.supports_data_type(data_type).map(|_| Self)
+ Self.supports_data_type(data_type).map(|()| Self)
}
fn validate(data_type: &DataType, _metadata: Self::Metadata) -> Result<(),
ArrowError> {
diff --git a/arrow-schema/src/ffi.rs b/arrow-schema/src/ffi.rs
index 7b6332632e..2279d2d50f 100644
--- a/arrow-schema/src/ffi.rs
+++ b/arrow-schema/src/ffi.rs
@@ -207,7 +207,7 @@ impl FFI_ArrowSchema {
})?;
metadata_serialized.extend(num_entries.to_ne_bytes());
- for (key, value) in metadata.into_iter() {
+ for (key, value) in metadata {
let key_len: i32 = key.as_ref().len().try_into().map_err(|_| {
ArrowError::CDataInterface(format!(
"metadata key can only have {} bytes, but {} were
provided",
@@ -813,7 +813,7 @@ impl TryFrom<&Field> for FFI_ArrowSchema {
Flags::empty()
};
- if let Some(true) = field.dict_is_ordered() {
+ if field.dict_is_ordered() == Some(true) {
flags |= Flags::DICTIONARY_ORDERED;
}
@@ -1001,9 +1001,9 @@ mod tests {
[].into(),
[("key".to_string(), "value".to_string())].into(),
[
- ("key".to_string(), "".to_string()),
+ ("key".to_string(), String::new()),
("ascii123".to_string(), "你好".to_string()),
- ("".to_string(), "value".to_string()),
+ (String::new(), "value".to_string()),
]
.into(),
];
diff --git a/arrow-schema/src/field.rs b/arrow-schema/src/field.rs
index a0f6fb9a3e..66874f6672 100644
--- a/arrow-schema/src/field.rs
+++ b/arrow-schema/src/field.rs
@@ -927,7 +927,7 @@ impl Field {
&& (self.nullable || !other.nullable)
// make sure self.metadata is a superset of other.metadata
&& other.metadata.iter().all(|(k, v1)| {
- self.metadata.get(k).map(|v2| v1 == v2).unwrap_or_default()
+ self.metadata.get(k).is_some_and(|v2| v1 == v2)
})
}
@@ -1497,7 +1497,7 @@ mod test {
#[test]
fn test_field_with_nonempty_metadata_serde() {
let mut metadata = HashMap::new();
- metadata.insert("hi".to_owned(), "".to_owned());
+ metadata.insert("hi".to_owned(), String::new());
let field = Field::new("name", DataType::Boolean,
false).with_metadata(metadata);
assert_binary_serde_round_trip(field)
diff --git a/arrow-schema/src/schema.rs b/arrow-schema/src/schema.rs
index 809b2a33a5..54e513635b 100644
--- a/arrow-schema/src/schema.rs
+++ b/arrow-schema/src/schema.rs
@@ -293,7 +293,7 @@ impl Schema {
let Schema { metadata, fields } = schema;
// merge metadata
- for (key, value) in metadata.into_iter() {
+ for (key, value) in metadata {
if let Some(old_val) = out_meta.get(&key)
&& old_val != &value
{
@@ -507,7 +507,7 @@ impl Schema {
&& other
.metadata
.iter()
- .all(|(k, v1)| self.metadata.get(k).map(|v2| v1 ==
v2).unwrap_or_default())
+ .all(|(k, v1)| self.metadata.get(k).is_some_and(|v2| v1 == v2))
}
}
diff --git a/arrow-select/src/coalesce.rs b/arrow-select/src/coalesce.rs
index e9e63d3e24..1889a0360e 100644
--- a/arrow-select/src/coalesce.rs
+++ b/arrow-select/src/coalesce.rs
@@ -1716,7 +1716,7 @@ mod tests {
impl Default for Test {
fn default() -> Self {
Self {
- name: "".to_string(),
+ name: String::new(),
input_batches: vec![],
filters: vec![],
schema: None,
diff --git a/arrow-select/src/take.rs b/arrow-select/src/take.rs
index fccf354b94..f8ff461d2c 100644
--- a/arrow-select/src/take.rs
+++ b/arrow-select/src/take.rs
@@ -599,7 +599,7 @@ fn take_bytes<T: ByteArrayType, IndexType:
ArrowPrimitiveType>(
let mut offset = 0;
- for (start, end) in source_ranges.into_iter() {
+ for (start, end) in source_ranges {
let value_len = end - start;
// SAFETY: caller guarantees each (start, end) is in-bounds of
`src`.
// `dst` asserted above to include the required capacity.
diff --git a/arrow-string/src/binary_like.rs b/arrow-string/src/binary_like.rs
index a66400aa78..3759ff8573 100644
--- a/arrow-string/src/binary_like.rs
+++ b/arrow-string/src/binary_like.rs
@@ -132,7 +132,7 @@ fn vectored_iter<'a, T: BinaryArrayType<'a> + 'a>(
let nulls = a_v.nulls();
let keys = a_v.normalized_keys();
keys.into_iter().enumerate().map(move |(idx, key)| {
- if nulls.map(|n| n.is_null(idx)).unwrap_or_default() || a.is_null(key)
{
+ if nulls.is_some_and(|n| n.is_null(idx)) || a.is_null(key) {
return None;
}
Some(a.value(key))
diff --git a/arrow-string/src/like.rs b/arrow-string/src/like.rs
index f12e70d387..5fc75d81c9 100644
--- a/arrow-string/src/like.rs
+++ b/arrow-string/src/like.rs
@@ -374,7 +374,7 @@ fn vectored_iter<'a, T: StringArrayType<'a> + 'a>(
let nulls = a_v.nulls();
let keys = a_v.normalized_keys();
keys.into_iter().enumerate().map(move |(idx, key)| {
- if nulls.map(|n| n.is_null(idx)).unwrap_or_default() || a.is_null(key)
{
+ if nulls.is_some_and(|n| n.is_null(idx)) || a.is_null(key) {
return None;
}
Some(a.value(key))
diff --git a/parquet-variant-compute/src/variant_get.rs
b/parquet-variant-compute/src/variant_get.rs
index 04a2690b1e..7150992160 100644
--- a/parquet-variant-compute/src/variant_get.rs
+++ b/parquet-variant-compute/src/variant_get.rs
@@ -4862,7 +4862,7 @@ mod test {
use arrow::datatypes::Int64Type;
let string_array: ArrayRef = Arc::new(StringArray::from(vec![
- r#"[[1, 2], [3]]"#,
+ "[[1, 2], [3]]",
r#"[[4], "not a list", [5, 6]]"#,
]));
let variant_array =
ArrayRef::from(json_to_variant(&string_array).unwrap());
@@ -4940,7 +4940,7 @@ mod test {
#[test]
fn test_variant_get_list_like_unsafe_cast_preserves_null_elements() {
- let string_array: ArrayRef = Arc::new(StringArray::from(vec![r#"[1,
null, 3]"#]));
+ let string_array: ArrayRef = Arc::new(StringArray::from(vec!["[1,
null, 3]"]));
let variant_array =
ArrayRef::from(json_to_variant(&string_array).unwrap());
let cast_options = CastOptions {
safe: false,
diff --git a/parquet-variant-compute/src/variant_to_arrow.rs
b/parquet-variant-compute/src/variant_to_arrow.rs
index d7c61b7653..4c4ac367fb 100644
--- a/parquet-variant-compute/src/variant_to_arrow.rs
+++ b/parquet-variant-compute/src/variant_to_arrow.rs
@@ -1419,7 +1419,7 @@ struct FakeNullBuilder {
}
impl FakeNullBuilder {
- fn append_value(&mut self, _: ()) {
+ fn append_value(&mut self, (): ()) {
self.item_count += 1;
}
diff --git a/parquet-variant-json/src/to_json.rs
b/parquet-variant-json/src/to_json.rs
index 9e538877fb..799a752285 100644
--- a/parquet-variant-json/src/to_json.rs
+++ b/parquet-variant-json/src/to_json.rs
@@ -887,7 +887,7 @@ mod tests {
JsonTest {
variant: Variant::from(""),
expected_json: "\"\"",
- expected_value: Value::String("".to_string()),
+ expected_value: Value::String(String::new()),
}
.run();
@@ -917,7 +917,7 @@ mod tests {
JsonTest {
variant: Variant::Binary(b""),
expected_json: "\"\"", // empty base64
- expected_value: Value::String("".to_string()),
+ expected_value: Value::String(String::new()),
}
.run();
diff --git a/parquet-variant/src/builder.rs b/parquet-variant/src/builder.rs
index b176b4e615..2624cafcdb 100644
--- a/parquet-variant/src/builder.rs
+++ b/parquet-variant/src/builder.rs
@@ -36,11 +36,11 @@ pub(crate) const UNIX_EPOCH_DATE: chrono::NaiveDate =
chrono::NaiveDate::from_ymd_opt(1970, 1, 1).unwrap();
fn primitive_header(primitive_type: VariantPrimitiveType) -> u8 {
- (primitive_type as u8) << 2 | VariantBasicType::Primitive as u8
+ ((primitive_type as u8) << 2) | VariantBasicType::Primitive as u8
}
fn short_string_header(len: usize) -> u8 {
- (len as u8) << 2 | VariantBasicType::ShortString as u8
+ ((len as u8) << 2) | VariantBasicType::ShortString as u8
}
pub(crate) fn int_size(v: usize) -> OffsetSizeBytes {
diff --git a/parquet-variant/src/builder/list.rs
b/parquet-variant/src/builder/list.rs
index 4cbce2a093..3084ffd4fe 100644
--- a/parquet-variant/src/builder/list.rs
+++ b/parquet-variant/src/builder/list.rs
@@ -222,7 +222,7 @@ where
V: Into<Variant<'m, 'v>>,
{
fn extend<T: IntoIterator<Item = V>>(&mut self, iter: T) {
- for v in iter.into_iter() {
+ for v in iter {
self.append_value(v);
}
}
diff --git a/parquet-variant/src/builder/metadata.rs
b/parquet-variant/src/builder/metadata.rs
index ea1a6d4694..003407847a 100644
--- a/parquet-variant/src/builder/metadata.rs
+++ b/parquet-variant/src/builder/metadata.rs
@@ -215,7 +215,7 @@ impl WritableMetadataBuilder {
metadata_buffer.reserve(metadata_size);
// Write header: version=1, field names are sorted, with calculated
offset_size
- metadata_buffer.push(0x01 | (is_sorted as u8) << 4 | ((offset_size -
1) << 6));
+ metadata_buffer.push(0x01 | ((is_sorted as u8) << 4) | ((offset_size -
1) << 6));
// Write dictionary size
write_offset(metadata_buffer, nkeys, offset_size);
diff --git a/parquet-variant/src/builder/object.rs
b/parquet-variant/src/builder/object.rs
index 670e3f7d76..41d5e40c9d 100644
--- a/parquet-variant/src/builder/object.rs
+++ b/parquet-variant/src/builder/object.rs
@@ -331,7 +331,7 @@ where
V: Into<Variant<'m, 'v>>,
{
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T) {
- for (key, value) in iter.into_iter() {
+ for (key, value) in iter {
self.insert(key.as_ref(), value);
}
}
diff --git a/parquet-variant/src/decoder.rs b/parquet-variant/src/decoder.rs
index ea03f2e2a4..ce7c09a36c 100644
--- a/parquet-variant/src/decoder.rs
+++ b/parquet-variant/src/decoder.rs
@@ -589,14 +589,14 @@ mod tests {
#[test]
fn test_short_string_exact_length() {
let data = b"Helloo";
- let result = decode_short_string(1 | 5 << 2, data).unwrap();
+ let result = decode_short_string(1 | (5 << 2), data).unwrap();
assert_eq!(result.0, "Hello");
}
#[test]
fn test_short_string_truncated_length() {
let data = b"Hel";
- let result = decode_short_string(1 | 5 << 2, data);
+ let result = decode_short_string(1 | (5 << 2), data);
assert!(matches!(result, Err(ArrowError::InvalidArgumentError(_))));
}
diff --git a/parquet-variant/src/utils.rs b/parquet-variant/src/utils.rs
index 33f65c4e2b..b2e2f654e0 100644
--- a/parquet-variant/src/utils.rs
+++ b/parquet-variant/src/utils.rs
@@ -187,7 +187,7 @@ pub(crate) fn parse_path(s: &str) ->
Result<Vec<VariantPathElement<'_>>, ArrowEr
};
let bytes = s.as_bytes();
- if let Some(b'.') = bytes.first() {
+ if bytes.first() == Some(&b'.') {
return Err(ArrowError::ParseError("Unexpected leading '.'".into()));
}
diff --git a/parquet/benches/metadata.rs b/parquet/benches/metadata.rs
index eaa36a9f80..0ec1b3cd17 100644
--- a/parquet/benches/metadata.rs
+++ b/parquet/benches/metadata.rs
@@ -158,9 +158,9 @@ fn encoded_meta(is_nullable: bool, has_lists: bool,
write_path_in_schema: bool)
fn get_footer_bytes(data: Bytes) -> Bytes {
let footer_bytes = data.slice(data.len() - 8..);
let footer_len = footer_bytes[0] as u32
- | (footer_bytes[1] as u32) << 8
- | (footer_bytes[2] as u32) << 16
- | (footer_bytes[3] as u32) << 24;
+ | ((footer_bytes[1] as u32) << 8)
+ | ((footer_bytes[2] as u32) << 16)
+ | ((footer_bytes[3] as u32) << 24);
let meta_start = data.len() - footer_len as usize - 8;
let meta_end = data.len() - 8;
data.slice(meta_start..meta_end)
diff --git a/parquet/benches/row_group_index_reader.rs
b/parquet/benches/row_group_index_reader.rs
index 1fadfb5d4b..4c7968ae97 100644
--- a/parquet/benches/row_group_index_reader.rs
+++ b/parquet/benches/row_group_index_reader.rs
@@ -74,7 +74,7 @@ impl ExtensionType for RowGroupIndex {
data_type: &ArrowDataType,
_metadata: Self::Metadata,
) -> Result<Self, arrow_schema::ArrowError> {
- RowGroupIndex.supports_data_type(data_type).map(|_| Self)
+ RowGroupIndex.supports_data_type(data_type).map(|()| Self)
}
}
diff --git a/parquet/src/arrow/arrow_reader/mod.rs
b/parquet/src/arrow/arrow_reader/mod.rs
index bbff081b2c..8d85dc088d 100644
--- a/parquet/src/arrow/arrow_reader/mod.rs
+++ b/parquet/src/arrow/arrow_reader/mod.rs
@@ -2125,7 +2125,7 @@ pub(crate) mod tests {
)
.with_metadata(HashMap::from_iter(vec![(
"adjusted_to_utc".to_string(),
- "".to_string(),
+ String::new(),
)])),
Field::new(
"time_micros",
@@ -2134,7 +2134,7 @@ pub(crate) mod tests {
)
.with_metadata(HashMap::from_iter(vec![(
"adjusted_to_utc".to_string(),
- "".to_string(),
+ String::new(),
)])),
]));
diff --git a/parquet/src/arrow/arrow_reader/statistics.rs
b/parquet/src/arrow/arrow_reader/statistics.rs
index 755d7831ca..7ff4a3a4e1 100644
--- a/parquet/src/arrow/arrow_reader/statistics.rs
+++ b/parquet/src/arrow/arrow_reader/statistics.rs
@@ -1541,7 +1541,7 @@ impl<'a> StatisticsConverter<'a> {
};
let mut builder = UInt64Array::builder(10);
- for metadata in metadatas.into_iter() {
+ for metadata in metadatas {
let row_count = metadata.num_rows();
let row_count: u64 = row_count.try_into().map_err(|e| {
arrow_err!(format!(
diff --git a/parquet/src/arrow/arrow_writer/levels.rs
b/parquet/src/arrow/arrow_writer/levels.rs
index ead1ba0d9a..40417ef73c 100644
--- a/parquet/src/arrow/arrow_writer/levels.rs
+++ b/parquet/src/arrow/arrow_writer/levels.rs
@@ -2162,12 +2162,12 @@ mod tests {
let list_field = Field::new("col", list_type, true);
let expected = vec![
- r#""#.to_string(),
- r#""#.to_string(),
- r#"[]"#.to_string(),
- r#"[{list: [3, ], integers: }]"#.to_string(),
- r#"[, {list: , integers: 5}]"#.to_string(),
- r#"[]"#.to_string(),
+ String::new(),
+ String::new(),
+ "[]".to_string(),
+ "[{list: [3, ], integers: }]".to_string(),
+ "[, {list: , integers: 5}]".to_string(),
+ "[]".to_string(),
];
let actual: Vec<_> = (0..6)
diff --git a/parquet/src/arrow/arrow_writer/mod.rs
b/parquet/src/arrow/arrow_writer/mod.rs
index 6c3ce7811b..0b4cdfff42 100644
--- a/parquet/src/arrow/arrow_writer/mod.rs
+++ b/parquet/src/arrow/arrow_writer/mod.rs
@@ -4828,7 +4828,7 @@ mod tests {
// Verify data is as expected
- let expected = r#"
+ let expected = r"
+-------------------------------------------------------------------------------------------------------+
| struct_b
|
+-------------------------------------------------------------------------------------------------------+
@@ -4840,7 +4840,7 @@ mod tests {
| {list: [{leaf_a: 6, leaf_b: }, {leaf_a: 7, leaf_b: }, {leaf_a:
8, leaf_b: }, {leaf_a: 9, leaf_b: 1}]} |
| {list: [{leaf_a: 10, leaf_b: }]}
|
+-------------------------------------------------------------------------------------------------------+
- "#.trim().split('\n').map(|x| x.trim()).collect::<Vec<_>>().join("\n");
+ ".trim().split('\n').map(|x| x.trim()).collect::<Vec<_>>().join("\n");
let actual = pretty_format_batches(batches).unwrap().to_string();
assert_eq!(actual, expected);
diff --git a/parquet/src/arrow/async_reader/mod.rs
b/parquet/src/arrow/async_reader/mod.rs
index 8b71ce0f1a..903a3952d0 100644
--- a/parquet/src/arrow/async_reader/mod.rs
+++ b/parquet/src/arrow/async_reader/mod.rs
@@ -168,7 +168,7 @@ pub trait AsyncFileReader: Send {
async move {
let mut result = Vec::with_capacity(ranges.len());
- for range in ranges.into_iter() {
+ for range in ranges {
let data = self.get_bytes(range).await?;
result.push(data);
}
diff --git a/parquet/src/arrow/schema/complex.rs
b/parquet/src/arrow/schema/complex.rs
index 99dc3d4dc7..9277c8e193 100644
--- a/parquet/src/arrow/schema/complex.rs
+++ b/parquet/src/arrow/schema/complex.rs
@@ -85,9 +85,11 @@ impl ParquetField {
list_data_type: Option<DataType>,
) -> Result<Self, ParquetError> {
let arrow_field = match &list_data_type {
- Some(DataType::List(field_hint))
- | Some(DataType::LargeList(field_hint))
- | Some(DataType::FixedSizeList(field_hint, _)) =>
Some(field_hint.as_ref()),
+ Some(
+ DataType::List(field_hint)
+ | DataType::LargeList(field_hint)
+ | DataType::FixedSizeList(field_hint, _),
+ ) => Some(field_hint.as_ref()),
Some(_) => {
return Err(general_err!(
"Internal error: should be validated earlier that
list_data_type is only a type of list"
diff --git a/parquet/src/arrow/schema/mod.rs b/parquet/src/arrow/schema/mod.rs
index 500745c6e7..110c799b42 100644
--- a/parquet/src/arrow/schema/mod.rs
+++ b/parquet/src/arrow/schema/mod.rs
@@ -1880,7 +1880,7 @@ mod tests {
)
.with_metadata(HashMap::from_iter(vec![(
"adjusted_to_utc".to_string(),
- "".to_string(),
+ String::new(),
)])),
Field::new("time_micro", DataType::Time64(TimeUnit::Microsecond),
true),
Field::new(
@@ -1890,7 +1890,7 @@ mod tests {
)
.with_metadata(HashMap::from_iter(vec![(
"adjusted_to_utc".to_string(),
- "".to_string(),
+ String::new(),
)])),
Field::new(
"ts_milli",
diff --git a/parquet/src/arrow/schema/virtual_type.rs
b/parquet/src/arrow/schema/virtual_type.rs
index dc9e191e8f..7acdc0c2c0 100644
--- a/parquet/src/arrow/schema/virtual_type.rs
+++ b/parquet/src/arrow/schema/virtual_type.rs
@@ -67,7 +67,7 @@ impl ExtensionType for RowGroupIndex {
}
fn try_new(data_type: &DataType, _metadata: Self::Metadata) ->
Result<Self, ArrowError> {
- Self.supports_data_type(data_type).map(|_| Self)
+ Self.supports_data_type(data_type).map(|()| Self)
}
fn validate(data_type: &DataType, _metadata: Self::Metadata) -> Result<(),
ArrowError> {
@@ -115,7 +115,7 @@ impl ExtensionType for RowNumber {
}
fn try_new(data_type: &DataType, _metadata: Self::Metadata) ->
Result<Self, ArrowError> {
- Self.supports_data_type(data_type).map(|_| Self)
+ Self.supports_data_type(data_type).map(|()| Self)
}
fn validate(data_type: &DataType, _metadata: Self::Metadata) -> Result<(),
ArrowError> {
diff --git a/parquet/src/basic.rs b/parquet/src/basic.rs
index 3208e3c188..a2a6ed011b 100644
--- a/parquet/src/basic.rs
+++ b/parquet/src/basic.rs
@@ -516,7 +516,7 @@ impl EncodingMask {
/// A mask consisting of unused bit positions, used for validation. This
includes the never
/// used GROUP_VAR_INT encoding value of `1`.
const ALLOWED_MASK: u32 =
- !(1u32 << (EncodingMask::MAX_ENCODING as u32 + 1)).wrapping_sub(1) | 1
<< 1;
+ !(1u32 << (EncodingMask::MAX_ENCODING as u32 + 1)).wrapping_sub(1) |
(1 << 1);
/// Attempt to create a new `EncodingMask` from an integer.
///
diff --git a/parquet/src/column/writer/mod.rs b/parquet/src/column/writer/mod.rs
index eb27af2cfb..c98469cf7c 100644
--- a/parquet/src/column/writer/mod.rs
+++ b/parquet/src/column/writer/mod.rs
@@ -1186,7 +1186,7 @@ impl<'a, E: ColumnValueEncoder> GenericColumnWriter<'a,
E> {
Type::FIXED_LEN_BYTE_ARRAY
if !matches!(
self.descr.logical_type_ref(),
- Some(&LogicalType::Decimal { .. }) |
Some(&LogicalType::Float16)
+ Some(&LogicalType::Decimal { .. } | &LogicalType::Float16)
) =>
{
true
@@ -1730,7 +1730,7 @@ fn is_nan<T: ParquetValueType>(basic_type_info:
&BasicTypeInfo, val: &T) -> bool
// taken from f16 impl, but skips creating f16. just compare the
bits as u16.
let val = val.as_bytes();
// Float16 is stored little endian
- let uval = (val[1] as u16) << 8 | val[0] as u16;
+ let uval = ((val[1] as u16) << 8) | val[0] as u16;
uval & 0x7FFFu16 > 0x7C00u16
}
_ => false,
diff --git a/parquet/src/compression.rs b/parquet/src/compression.rs
index 45b2b7edf9..cb1620e3fe 100644
--- a/parquet/src/compression.rs
+++ b/parquet/src/compression.rs
@@ -24,7 +24,7 @@
// therefore actually run as a doc test) rather than to the `use` statement
below.
#![cfg_attr(
feature = "experimental",
- doc = r##"
+ doc = r"
# Example
```no_run
@@ -47,7 +47,7 @@ codec.decompress(&compressed[..], &mut output, None).unwrap();
assert_eq!(output, data);
```
-"##
+"
)]
use crate::basic::Compression as CodecType;
use crate::errors::{ParquetError, Result};
@@ -350,7 +350,7 @@ impl GzipLevel {
///
/// Compression levels must be valid (i.e. be acceptable for
[`flate2::Compression`]).
pub fn try_new(level: u32) -> Result<Self> {
- Self::is_valid_level(level).map(|_| Self(level))
+ Self::is_valid_level(level).map(|()| Self(level))
}
/// Returns the compression level.
@@ -432,7 +432,7 @@ impl BrotliLevel {
///
/// Compression levels must be valid.
pub fn try_new(level: u32) -> Result<Self> {
- Self::is_valid_level(level).map(|_| Self(level))
+ Self::is_valid_level(level).map(|()| Self(level))
}
/// Returns the compression level.
@@ -588,7 +588,7 @@ impl ZstdLevel {
///
/// Compression levels must be valid (i.e. be acceptable for
[`zstd::compression_level_range`]).
pub fn try_new(level: i32) -> Result<Self> {
- Self::is_valid_level(level).map(|_| Self(level))
+ Self::is_valid_level(level).map(|()| Self(level))
}
/// Returns the compression level.
diff --git a/parquet/src/file/metadata/push_decoder.rs
b/parquet/src/file/metadata/push_decoder.rs
index 4212b58ce4..42545f1565 100644
--- a/parquet/src/file/metadata/push_decoder.rs
+++ b/parquet/src/file/metadata/push_decoder.rs
@@ -50,7 +50,7 @@ use std::sync::Arc;
///
#[cfg_attr(
feature = "arrow",
- doc = r##"
+ doc = r#"
```rust
# use std::ops::Range;
# use bytes::Bytes;
@@ -98,7 +98,7 @@ loop {
}
# }
```
-"##
+"#
)]
///
/// # Example with "prefetching"
@@ -122,7 +122,7 @@ loop {
/// for other reasons.
#[cfg_attr(
feature = "arrow",
- doc = r##"
+ doc = r#"
```rust
# use std::ops::Range;
# use bytes::Bytes;
@@ -160,7 +160,7 @@ decoder.push_ranges(vec![0..file_len],
vec![prefetched_bytes]).unwrap();
}
# }
```
-"##
+"#
)]
///
/// # Example using [`AsyncRead`]
@@ -172,7 +172,7 @@ decoder.push_ranges(vec![0..file_len],
vec![prefetched_bytes]).unwrap();
/// decoder.
#[cfg_attr(
feature = "arrow",
- doc = r##"
+ doc = r#"
```rust
# use std::ops::Range;
# use bytes::Bytes;
@@ -215,7 +215,7 @@ async fn decode_metadata(
}
}
```
-"##
+"#
)]
/// [`AsyncRead`]: tokio::io::AsyncRead
#[derive(Debug)]
diff --git a/parquet/src/file/metadata/reader.rs
b/parquet/src/file/metadata/reader.rs
index 78414ffdcb..43bd339930 100644
--- a/parquet/src/file/metadata/reader.rs
+++ b/parquet/src/file/metadata/reader.rs
@@ -930,7 +930,7 @@ mod tests {
let mut bytes = bytes_for_range(452505..len);
loop {
match reader.try_parse_sized(&bytes, len) {
- Ok(_) => break,
+ Ok(()) => break,
Err(ParquetError::NeedMoreData(needed)) => {
bytes = bytes_for_range(len - needed as u64..len);
if reader.has_metadata() {
diff --git a/parquet/src/file/serialized_reader.rs
b/parquet/src/file/serialized_reader.rs
index b52aac367b..fe9a5c0486 100644
--- a/parquet/src/file/serialized_reader.rs
+++ b/parquet/src/file/serialized_reader.rs
@@ -2332,7 +2332,7 @@ mod tests {
//col11->timestamp_col: INT96 UNCOMPRESSED DO:0 FPO:490093
SZ:111948/111948/1.00 VC:7300 ENC:BIT_PACKED,RLE,PLAIN ST:[num_nulls: 0,
min/max not defined]
//Notice: min_max values for each page for this col not exits.
assert!(!&column_index[0][10].is_sorted());
- if let ColumnIndexMetaData::NONE = &column_index[0][10] {
+ if column_index[0][10] == ColumnIndexMetaData::NONE {
assert_eq!(row_group_offset_indexes[10].page_locations.len(), 974);
} else {
unreachable!()
diff --git a/parquet/src/geospatial/accumulator.rs
b/parquet/src/geospatial/accumulator.rs
index 3aad1060e0..c204db94fa 100644
--- a/parquet/src/geospatial/accumulator.rs
+++ b/parquet/src/geospatial/accumulator.rs
@@ -34,7 +34,7 @@ pub fn try_new_geo_stats_accumulator(
) -> Option<Box<dyn GeoStatsAccumulator>> {
if !matches!(
descr.logical_type_ref(),
- Some(LogicalType::Geometry { .. }) | Some(LogicalType::Geography { ..
})
+ Some(LogicalType::Geometry { .. } | LogicalType::Geography { .. })
) {
return None;
}
diff --git a/parquet/src/parquet_thrift.rs b/parquet/src/parquet_thrift.rs
index 84d6825f50..a3da857411 100644
--- a/parquet/src/parquet_thrift.rs
+++ b/parquet/src/parquet_thrift.rs
@@ -499,11 +499,11 @@ pub(crate) trait ThriftCompactInputProtocol<'a> {
// boolean field has no data
FieldType::BooleanFalse | FieldType::BooleanTrue => Ok(()),
FieldType::Byte => self.read_i8().map(|_| ()),
- FieldType::I16 => self.skip_vlq().map(|_| ()),
- FieldType::I32 => self.skip_vlq().map(|_| ()),
- FieldType::I64 => self.skip_vlq().map(|_| ()),
- FieldType::Double => self.skip_bytes(8).map(|_| ()),
- FieldType::Binary => self.skip_binary().map(|_| ()),
+ FieldType::I16 => self.skip_vlq(),
+ FieldType::I32 => self.skip_vlq(),
+ FieldType::I64 => self.skip_vlq(),
+ FieldType::Double => self.skip_bytes(8),
+ FieldType::Binary => self.skip_binary(),
// see
https://github.com/apache/thrift/blob/master/doc/specs/thrift-compact-protocol.md#struct
FieldType::Struct => {
loop {
@@ -541,7 +541,7 @@ pub(crate) trait ThriftCompactInputProtocol<'a> {
Ok(())
}
// see
https://github.com/apache/thrift/blob/master/doc/specs/thrift-compact-protocol.md#universal-unique-identifier-encoding
- FieldType::Uuid => self.skip_bytes(16).map(|_| ()),
+ FieldType::Uuid => self.skip_bytes(16),
_ => Err(ThriftProtocolError::SkipUnsupportedType(field_type)),
}
}
@@ -829,7 +829,7 @@ impl<W: Write> ThriftCompactOutputProtocol<W> {
) -> Result<()> {
let delta = field_id.wrapping_sub(last_field_id);
if delta > 0 && delta <= 0xf {
- self.write_byte((delta as u8) << 4 | field_type as u8)
+ self.write_byte(((delta as u8) << 4) | field_type as u8)
} else {
self.write_byte(field_type as u8)?;
self.write_i16(field_id)
@@ -839,7 +839,7 @@ impl<W: Write> ThriftCompactOutputProtocol<W> {
/// Used to indicate the start of a list of `element_type` elements.
pub(crate) fn write_list_begin(&mut self, element_type: ElementType, len:
usize) -> Result<()> {
if len < 15 {
- self.write_byte((len as u8) << 4 | element_type as u8)
+ self.write_byte(((len as u8) << 4) | element_type as u8)
} else {
self.write_byte(0xf0u8 | element_type as u8)?;
self.write_vlq(len as _)
diff --git a/parquet/src/record/triplet.rs b/parquet/src/record/triplet.rs
index b4d39bbbd9..db3088c715 100644
--- a/parquet/src/record/triplet.rs
+++ b/parquet/src/record/triplet.rs
@@ -555,7 +555,7 @@ mod tests {
assert_eq!(iter.max_def_level(), descr.max_def_level());
assert_eq!(iter.max_rep_level(), descr.max_rep_level());
- while let Ok(true) = iter.read_next() {
+ while matches!(iter.read_next(), Ok(true)) {
assert!(iter.has_next());
if !iter.is_null() {
values.push(iter.current_value().unwrap());
@@ -589,7 +589,7 @@ mod tests {
#[test]
fn test_current_def_level_safe_after_exhaustion() {
let mut iter = open_triplet_iter("nulls.snappy.parquet", &["b_struct",
"b_c_int"], 256);
- while let Ok(true) = iter.read_next() {}
+ while matches!(iter.read_next(), Ok(true)) {}
assert!(!iter.has_next());
assert_eq!(iter.current_def_level(), 0);
}
@@ -601,7 +601,7 @@ mod tests {
&["a", "list", "element", "list", "element", "list", "element"],
256,
);
- while let Ok(true) = iter.read_next() {}
+ while matches!(iter.read_next(), Ok(true)) {}
assert!(!iter.has_next());
assert_eq!(iter.current_rep_level(), 0);
}
diff --git a/parquet/src/schema/parser.rs b/parquet/src/schema/parser.rs
index 071962aa4e..c6a79a8202 100644
--- a/parquet/src/schema/parser.rs
+++ b/parquet/src/schema/parser.rs
@@ -245,7 +245,7 @@ impl Parser<'_> {
.ok_or_else(|| general_err!("Expected name, found None"))?;
// Parse logical or converted type if exists
- let (logical_type, converted_type) = if let Some("(") =
self.tokenizer.next() {
+ let (logical_type, converted_type) = if self.tokenizer.next() ==
Some("(") {
let tpe = self
.tokenizer
.next()
@@ -269,7 +269,7 @@ impl Parser<'_> {
};
// Parse optional id
- let id = if let Some("=") = self.tokenizer.next() {
+ let id = if self.tokenizer.next() == Some("=") {
self.tokenizer.next().and_then(|v| v.parse::<i32>().ok())
} else {
self.tokenizer.backtrack();
@@ -311,8 +311,7 @@ impl Parser<'_> {
.ok_or_else(|| general_err!("Expected name, found None"))?;
// Parse converted type
- let (logical_type, converted_type, precision, scale) = if let
Some("(") =
- self.tokenizer.next()
+ let (logical_type, converted_type, precision, scale) = if
self.tokenizer.next() == Some("(")
{
let (mut logical, mut converted) = self
.tokenizer
@@ -337,13 +336,13 @@ impl Parser<'_> {
if let Some(tpe) = &logical {
match tpe {
LogicalType::Decimal { .. } => {
- if let Some("(") = self.tokenizer.next() {
+ if self.tokenizer.next() == Some("(") {
precision = parse_i32(
self.tokenizer.next(),
"Expected precision, found None",
"Failed to parse precision for DECIMAL type",
)?;
- if let Some(",") = self.tokenizer.next() {
+ if self.tokenizer.next() == Some(",") {
scale = parse_i32(
self.tokenizer.next(),
"Expected scale, found None",
@@ -358,13 +357,13 @@ impl Parser<'_> {
}
}
LogicalType::Time { .. } => {
- if let Some("(") = self.tokenizer.next() {
+ if self.tokenizer.next() == Some("(") {
let unit = parse_timeunit(
self.tokenizer.next(),
"Invalid timeunit found",
"Failed to parse timeunit for TIME type",
)?;
- if let Some(",") = self.tokenizer.next() {
+ if self.tokenizer.next() == Some(",") {
let is_adjusted_to_u_t_c = parse_bool(
self.tokenizer.next(),
"Invalid boolean found",
@@ -380,13 +379,13 @@ impl Parser<'_> {
}
}
LogicalType::Timestamp { .. } => {
- if let Some("(") = self.tokenizer.next() {
+ if self.tokenizer.next() == Some("(") {
let unit = parse_timeunit(
self.tokenizer.next(),
"Invalid timeunit found",
"Failed to parse timeunit for TIMESTAMP type",
)?;
- if let Some(",") = self.tokenizer.next() {
+ if self.tokenizer.next() == Some(",") {
let is_adjusted_to_u_t_c = parse_bool(
self.tokenizer.next(),
"Invalid boolean found",
@@ -401,57 +400,55 @@ impl Parser<'_> {
}
}
}
- LogicalType::Integer { .. } => {
- if let Some("(") = self.tokenizer.next() {
- let bit_width = parse_i32(
- self.tokenizer.next(),
- "Invalid bit_width found",
- "Failed to parse bit_width for INTEGER type",
- )? as i8;
- match physical_type {
- PhysicalType::INT32 => match bit_width {
- 8 | 16 | 32 => {}
- _ => {
- return Err(general_err!(
- "Incorrect bit width {} for INT32",
- bit_width
- ));
- }
- },
- PhysicalType::INT64 => {
- if bit_width != 64 {
- return Err(general_err!(
- "Incorrect bit width {} for INT64",
- bit_width
- ));
- }
- }
+ LogicalType::Integer { .. } if self.tokenizer.next() ==
Some("(") => {
+ let bit_width = parse_i32(
+ self.tokenizer.next(),
+ "Invalid bit_width found",
+ "Failed to parse bit_width for INTEGER type",
+ )? as i8;
+ match physical_type {
+ PhysicalType::INT32 => match bit_width {
+ 8 | 16 | 32 => {}
_ => {
return Err(general_err!(
- "Logical type Integer cannot be used
with physical type {}",
- physical_type
+ "Incorrect bit width {} for INT32",
+ bit_width
+ ));
+ }
+ },
+ PhysicalType::INT64 => {
+ if bit_width != 64 {
+ return Err(general_err!(
+ "Incorrect bit width {} for INT64",
+ bit_width
));
}
}
- if let Some(",") = self.tokenizer.next() {
- let is_signed = parse_bool(
- self.tokenizer.next(),
- "Invalid boolean found",
- "Failed to parse is_signed for INTEGER
type",
- )?;
- assert_token(self.tokenizer.next(), ")")?;
- logical = Some(LogicalType::integer(bit_width,
is_signed));
- converted =
ConvertedType::from(logical.clone());
- } else {
- // Invalid token for unit
- self.tokenizer.backtrack();
+ _ => {
+ return Err(general_err!(
+ "Logical type Integer cannot be used with
physical type {}",
+ physical_type
+ ));
}
}
+ if self.tokenizer.next() == Some(",") {
+ let is_signed = parse_bool(
+ self.tokenizer.next(),
+ "Invalid boolean found",
+ "Failed to parse is_signed for INTEGER type",
+ )?;
+ assert_token(self.tokenizer.next(), ")")?;
+ logical = Some(LogicalType::integer(bit_width,
is_signed));
+ converted = ConvertedType::from(logical.clone());
+ } else {
+ // Invalid token for unit
+ self.tokenizer.backtrack();
+ }
}
_ => {}
}
} else if converted == ConvertedType::DECIMAL {
- if let Some("(") = self.tokenizer.next() {
+ if self.tokenizer.next() == Some("(") {
// Parse precision
precision = parse_i32(
self.tokenizer.next(),
@@ -460,7 +457,7 @@ impl Parser<'_> {
)?;
// Parse scale
- scale = if let Some(",") = self.tokenizer.next() {
+ scale = if self.tokenizer.next() == Some(",") {
parse_i32(
self.tokenizer.next(),
"Expected scale, found None",
@@ -486,7 +483,7 @@ impl Parser<'_> {
};
// Parse optional id
- let id = if let Some("=") = self.tokenizer.next() {
+ let id = if self.tokenizer.next() == Some("=") {
self.tokenizer.next().and_then(|v| v.parse::<i32>().ok())
} else {
self.tokenizer.backtrack();
diff --git a/parquet/src/schema/printer.rs b/parquet/src/schema/printer.rs
index e43e09b30f..67d8861aaf 100644
--- a/parquet/src/schema/printer.rs
+++ b/parquet/src/schema/printer.rs
@@ -83,7 +83,7 @@ pub fn print_file_metadata(out: &mut dyn io::Write,
file_metadata: &FileMetaData
out,
" {}: {}",
kv.key,
- kv.value.as_ref().unwrap_or(&"".to_owned())
+ kv.value.as_ref().unwrap_or(&String::new())
);
}
}
diff --git a/parquet/src/schema/types.rs b/parquet/src/schema/types.rs
index 9934a85d0f..c7e66231fa 100644
--- a/parquet/src/schema/types.rs
+++ b/parquet/src/schema/types.rs
@@ -356,7 +356,7 @@ impl<'a> PrimitiveTypeBuilder<'a> {
}
// Check that logical type and physical type are compatible
match (logical_type, self.physical_type) {
- (LogicalType::Map, _) | (LogicalType::List, _) => {
+ (LogicalType::Map | LogicalType::List, _) => {
return Err(general_err!(
"{:?} cannot be applied to a primitive type for field
'{}'",
logical_type,
diff --git a/parquet/tests/encryption/encryption_async.rs
b/parquet/tests/encryption/encryption_async.rs
index 535ce1e56a..35fb98a9eb 100644
--- a/parquet/tests/encryption/encryption_async.rs
+++ b/parquet/tests/encryption/encryption_async.rs
@@ -109,7 +109,7 @@ async fn test_misspecified_encryption_keys() {
let decryption_properties = builder.build().unwrap();
match verify_encryption_test_file_read_async(&mut file,
decryption_properties).await {
- Ok(_) => {
+ Ok(()) => {
panic!("did not get expected error")
}
Err(e) => {
@@ -771,7 +771,7 @@ fn spawn_rg_join_and_finalize_task(
tokio::task::spawn(async move {
let num_cols = column_writer_tasks.len();
let mut finalized_rg = Vec::with_capacity(num_cols);
- for task in column_writer_tasks.into_iter() {
+ for task in column_writer_tasks {
let writer = task
.await
.map_err(|e| ParquetError::General(e.to_string()))??;
@@ -863,7 +863,7 @@ fn spawn_column_parallel_row_group_writer(
let mut col_writer_tasks = Vec::with_capacity(num_columns);
let mut col_array_channels = Vec::with_capacity(num_columns);
- for mut col_writer in col_writers.into_iter() {
+ for mut col_writer in col_writers {
let (send_array, mut receive_array) =
tokio::sync::mpsc::channel::<ArrowLeafColumn>(max_buffer_size);
col_array_channels.push(send_array);
diff --git a/parquet/tests/geospatial.rs b/parquet/tests/geospatial.rs
index 388b5c003d..28f4121283 100644
--- a/parquet/tests/geospatial.rs
+++ b/parquet/tests/geospatial.rs
@@ -437,7 +437,7 @@ mod test {
// Geometry with default CRS (defaults to OGC:CRS84 per Parquet
spec)
(LogicalType::geometry(None), r#"{"crs":"OGC:CRS84"}"#),
// Geometry with srid:0 should result in an unset (omitted) CRS
- (LogicalType::geometry(Some("srid:0".to_string())), r#"{}"#),
+ (LogicalType::geometry(Some("srid:0".to_string())), "{}"),
// Geometry with custom CRSes (authority:code and partial projjson)
(
LogicalType::geometry(Some("EPSG:4267".to_string())),
@@ -538,7 +538,7 @@ mod test {
// Test cases: (extension metadata JSON, expected LogicalType)
let test_cases = [
// Geometry with no CRS should be GEOMETRY(srid:0)
- (r#"{}"#, LogicalType::geometry(Some("srid:0".to_string()))),
+ ("{}", LogicalType::geometry(Some("srid:0".to_string()))),
// Geometry with string CRS
(
r#"{"crs":"EPSG:4267"}"#,