Skip to content

Commit 777ecb8

Browse files
authored
chore: Fix clippy and CI (#21287)
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - Closes #. ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. -->
1 parent 89f816a commit 777ecb8

File tree

20 files changed

+44
-6
lines changed

20 files changed

+44
-6
lines changed

datafusion-cli/tests/cli_integration.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,14 +414,12 @@ fn test_backtrace_output(#[case] query: &str) {
414414
let output = cmd.output().expect("Failed to execute command");
415415
let stdout = String::from_utf8_lossy(&output.stdout);
416416
let stderr = String::from_utf8_lossy(&output.stderr);
417-
let combined_output = format!("{}{}", stdout, stderr);
417+
let combined_output = format!("{stdout}{stderr}");
418418

419419
// Assert that the output includes literal 'backtrace'
420420
assert!(
421421
combined_output.to_lowercase().contains("backtrace"),
422-
"Expected output to contain 'backtrace', but got stdout: '{}' stderr: '{}'",
423-
stdout,
424-
stderr
422+
"Expected output to contain 'backtrace', but got stdout: '{stdout}' stderr: '{stderr}'"
425423
);
426424
}
427425

datafusion/common/src/error.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,6 @@ mod test {
12741274
// To pass the test the environment variable RUST_BACKTRACE should be set to 1 to enforce backtrace
12751275
#[cfg(feature = "backtrace")]
12761276
#[test]
1277-
#[expect(clippy::unnecessary_literal_unwrap)]
12781277
fn test_enabled_backtrace() {
12791278
match std::env::var("RUST_BACKTRACE") {
12801279
Ok(val) if val == "1" => {}

datafusion/common/src/hash_utils.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
2020
use arrow::array::types::{IntervalDayTime, IntervalMonthDayNano};
2121
use arrow::array::*;
22+
#[cfg(not(feature = "force_hash_collisions"))]
2223
use arrow::compute::take;
2324
use arrow::datatypes::*;
2425
#[cfg(not(feature = "force_hash_collisions"))]
2526
use arrow::{downcast_dictionary_array, downcast_primitive_array};
2627
use foldhash::fast::FixedState;
28+
#[cfg(not(feature = "force_hash_collisions"))]
2729
use itertools::Itertools;
30+
#[cfg(not(feature = "force_hash_collisions"))]
2831
use std::collections::HashMap;
2932
use std::hash::{BuildHasher, Hash, Hasher};
3033

@@ -198,6 +201,7 @@ hash_float_value!((half::f16, u16), (f32, u32), (f64, u64));
198201
/// Create a `SeedableRandomState` whose per-hasher seed incorporates `seed`.
199202
/// This folds the previous hash into the hasher's initial state so only the
200203
/// new value needs to pass through the hash function — same cost as `hash_one`.
204+
#[cfg(not(feature = "force_hash_collisions"))]
201205
#[inline]
202206
fn seeded_state(seed: u64) -> foldhash::fast::SeedableRandomState {
203207
foldhash::fast::SeedableRandomState::with_seed(
@@ -303,6 +307,7 @@ fn hash_array<T>(
303307
/// HAS_NULLS: do we have to check null in the inner loop
304308
/// HAS_BUFFERS: if true, array has external buffers; if false, all strings are inlined/ less then 12 bytes
305309
/// REHASH: if true, combining with existing hash, otherwise initializing
310+
#[cfg(not(feature = "force_hash_collisions"))]
306311
#[inline(never)]
307312
fn hash_string_view_array_inner<
308313
T: ByteViewType,
@@ -429,6 +434,7 @@ fn hash_generic_byte_view_array<T: ByteViewType>(
429434
/// - `HAS_NULL_KEYS`: Whether to check for null dictionary keys
430435
/// - `HAS_NULL_VALUES`: Whether to check for null dictionary values
431436
/// - `MULTI_COL`: Whether to combine with existing hash (true) or initialize (false)
437+
#[cfg(not(feature = "force_hash_collisions"))]
432438
#[inline(never)]
433439
fn hash_dictionary_inner<
434440
K: ArrowDictionaryKeyType,

datafusion/common/src/pruning.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ pub trait PruningStatistics {
121121
/// container, return `None` (the default).
122122
///
123123
/// Note: the returned array must contain [`Self::num_containers`] rows
124+
#[allow(clippy::allow_attributes, clippy::mutable_key_type)] // ScalarValue has interior mutability but is intentionally used as hash key
124125
fn contained(
125126
&self,
126127
column: &Column,
@@ -526,6 +527,7 @@ impl PruningStatistics for CompositePruningStatistics {
526527

527528
#[cfg(test)]
528529
#[expect(deprecated)]
530+
#[allow(clippy::allow_attributes, clippy::mutable_key_type)] // ScalarValue has interior mutability but is intentionally used as hash key
529531
mod tests {
530532
use crate::{
531533
ColumnStatistics,

datafusion/common/src/scalar/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4601,6 +4601,7 @@ impl ScalarValue {
46014601
/// Estimates [size](Self::size) of [`HashSet`] in bytes.
46024602
///
46034603
/// Includes the size of the [`HashSet`] container itself.
4604+
#[allow(clippy::allow_attributes, clippy::mutable_key_type)] // ScalarValue has interior mutability but is intentionally used as hash key
46044605
pub fn size_of_hashset<S>(set: &HashSet<Self, S>) -> usize {
46054606
size_of_val(set)
46064607
+ (size_of::<ScalarValue>() * set.capacity())
@@ -7263,6 +7264,8 @@ mod tests {
72637264
size_of::<Vec<ScalarValue>>() + (9 * size_of::<ScalarValue>()) + sv_size,
72647265
);
72657266

7267+
#[allow(clippy::allow_attributes, clippy::mutable_key_type)]
7268+
// ScalarValue has interior mutability but is intentionally used as hash key
72667269
let mut s = HashSet::with_capacity(0);
72677270
// do NOT clone `sv` here because this may shrink the vector capacity
72687271
s.insert(v.pop().unwrap());

datafusion/core/src/physical_planner.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,6 +2093,7 @@ fn get_physical_expr_pair(
20932093
/// A vector of unqualified filter expressions that can be passed to the TableProvider for execution.
20942094
/// Returns an empty vector if no applicable filters are found.
20952095
///
2096+
#[allow(clippy::allow_attributes, clippy::mutable_key_type)] // Expr contains Arc with interior mutability but is intentionally used as hash key
20962097
fn extract_dml_filters(
20972098
input: &Arc<LogicalPlan>,
20982099
target: &TableReference,

datafusion/datasource/src/file_groups.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ impl FileGroup {
488488
///
489489
/// Note: May return fewer groups than `max_target_partitions` when the
490490
/// number of unique partition values is less than the target.
491+
#[allow(clippy::allow_attributes, clippy::mutable_key_type)] // ScalarValue has interior mutability but is intentionally used as hash key
491492
pub fn group_by_partition_values(
492493
self,
493494
max_target_partitions: usize,

datafusion/execution/src/memory_pool/arrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl arrow_buffer::MemoryReservation for MemoryReservation {
5959
impl arrow_buffer::MemoryPool for ArrowMemoryPool {
6060
fn reserve(&self, size: usize) -> Box<dyn arrow_buffer::MemoryReservation> {
6161
let consumer = self.consumer.clone_with_new_id();
62-
let mut reservation = consumer.register(&self.inner);
62+
let reservation = consumer.register(&self.inner);
6363
reservation.grow(size);
6464

6565
Box::new(reservation)

datafusion/expr/src/logical_plan/builder.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,6 +2132,8 @@ pub fn wrap_projection_for_join_if_necessary(
21322132
.into_iter()
21332133
.map(Expr::Column)
21342134
.collect::<Vec<_>>();
2135+
#[allow(clippy::allow_attributes, clippy::mutable_key_type)]
2136+
// Expr contains Arc with interior mutability but is intentionally used as hash key
21352137
let join_key_items = alias_join_keys
21362138
.iter()
21372139
.flat_map(|expr| expr.try_as_col().is_none().then_some(expr))

datafusion/functions-aggregate/src/median.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ impl<T: ArrowNumericType> Accumulator for MedianAccumulator<T> {
285285
size_of_val(self) + self.all_values.capacity() * size_of::<T::Native>()
286286
}
287287

288+
#[allow(clippy::allow_attributes, clippy::mutable_key_type)] // ScalarValue has interior mutability but is intentionally used as hash key
288289
fn retract_batch(&mut self, values: &[ArrayRef]) -> Result<()> {
289290
let mut to_remove: HashMap<ScalarValue, usize> = HashMap::new();
290291

0 commit comments

Comments
 (0)