diff --git a/datafusion/core/benches/map_query_sql.rs b/datafusion/core/benches/map_query_sql.rs index 063b8e6c86bb..76b8e3ba7c3a 100644 --- a/datafusion/core/benches/map_query_sql.rs +++ b/datafusion/core/benches/map_query_sql.rs @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +use std::collections::HashSet; use std::sync::Arc; use arrow::array::{ArrayRef, Int32Array, RecordBatch}; @@ -33,8 +34,15 @@ mod data_utils; fn build_keys(rng: &mut ThreadRng) -> Vec { let mut keys = vec![]; - for _ in 0..1000 { - keys.push(rng.random_range(0..9999).to_string()); + let mut seen = HashSet::with_capacity(1000); + // Generate unique keys by tracking seen keys + while keys.len() < 1000 { + let key = rng.random_range(0..9999).to_string(); + if seen.insert(key.clone()) { + // Only push if it's a new unique key + keys.push(key); + } + // If key was already in set, skip it and generate another } keys }