akurmustafa commented on code in PR #12992: URL: https://github.com/apache/datafusion/pull/12992#discussion_r1806732228
########## datafusion/physical-expr/src/equivalence/mod.rs: ########## @@ -446,11 +446,99 @@ mod tests { ( field.name(), // Generate random values for columns that do not occur in any of the groups (equivalence, ordering equivalence, constants) - elem.unwrap_or_else(|| generate_random_array(n_elem, n_distinct)), + elem.unwrap_or_else(|| { + generate_random_f64_array(n_elem, n_distinct, &mut rng) + }), ) }) .collect(); Ok(RecordBatch::try_from_iter(res)?) } + + // Helper function to get sort columns from a batch + fn get_sort_columns( + batch: &RecordBatch, + ordering: LexOrderingRef, + ) -> Result<Vec<SortColumn>> { + ordering + .iter() + .map(|expr| expr.evaluate_to_sort_column(batch)) + .collect::<Result<Vec<_>>>() + } + + // Utility function to generate random f64 array + fn generate_random_f64_array( + n_elems: usize, + n_distinct: usize, + rng: &mut StdRng, + ) -> ArrayRef { + let values: Vec<f64> = (0..n_elems) + .map(|_| rng.gen_range(0..n_distinct) as f64 / 2.0) Review Comment: `rng.gen_range(0..n_distinct)` generates number as integer. This is done to convert them to the float (`as f64` would also work but when we divide by 2.0 floating point is more visible). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org