Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions datafusion/functions-aggregate-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ workspace = true
[lib]
name = "datafusion_functions_aggregate_common"

[features]
# Used for testing ONLY: causes all values to hash to the same value (test for collisions)
force_hash_collisions = ["datafusion-common/force_hash_collisions"]

[dependencies]
arrow = { workspace = true }
datafusion-common = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,16 @@ impl Accumulator for BytesViewDistinctCountAccumulator {
}
}

#[cfg(test)]
/// With `force_hash_collisions` every distinct value collides into the same
/// hash bucket, so both `ArrowBytesSet`/`ArrowBytesViewSet` degrade to a
/// linear scan per insert. These tests insert up to 500,000 distinct values
/// per accumulator (twice, once lazily constructed and once pre-allocated),
/// which is O(n) under a real hash and O(n^2) under a forced collision,
/// turning a sub-second run into a multi-hour one and hanging CI (see
/// apache/datafusion#25011). Skipped under that feature, matching the
/// `count_distinct_spill` precedent in
/// `datafusion/core/tests/memory_limit/mod.rs`.
#[cfg(all(test, not(feature = "force_hash_collisions")))]
mod tests {
use super::*;
use arrow::array::{StringArray, StringViewArray};
Expand Down