Skip to content

Commit 7002a00

Browse files
authored
Set aggregation hash seed (apache#16165)
1 parent 00132da commit 7002a00

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

datafusion/physical-plan/src/aggregates/group_values/multi_group_by/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl<const STREAMING: bool> GroupValuesColumn<STREAMING> {
270270
map_size: 0,
271271
group_values: vec![],
272272
hashes_buffer: Default::default(),
273-
random_state: Default::default(),
273+
random_state: crate::aggregates::AGGREGATION_HASH_SEED,
274274
})
275275
}
276276

datafusion/physical-plan/src/aggregates/group_values/row.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl GroupValuesRows {
106106
group_values: None,
107107
hashes_buffer: Default::default(),
108108
rows_buffer,
109-
random_state: Default::default(),
109+
random_state: crate::aggregates::AGGREGATION_HASH_SEED,
110110
})
111111
}
112112
}

datafusion/physical-plan/src/aggregates/group_values/single_group_by/primitive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<T: ArrowPrimitiveType> GroupValuesPrimitive<T> {
105105
map: HashTable::with_capacity(128),
106106
values: Vec::with_capacity(128),
107107
null_group: None,
108-
random_state: Default::default(),
108+
random_state: crate::aggregates::AGGREGATION_HASH_SEED,
109109
}
110110
}
111111
}

datafusion/physical-plan/src/aggregates/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ mod row_hash;
5858
mod topk;
5959
mod topk_stream;
6060

61+
/// Hard-coded seed for aggregations to ensure hash values differ from `RepartitionExec`, avoiding collisions.
62+
const AGGREGATION_HASH_SEED: ahash::RandomState =
63+
ahash::RandomState::with_seeds('A' as u64, 'G' as u64, 'G' as u64, 'R' as u64);
64+
6165
/// Aggregation modes
6266
///
6367
/// See [`Accumulator::state`] for background information on multi-phase

0 commit comments

Comments
 (0)