simonvandel commented on code in PR #14675: URL: https://github.com/apache/datafusion/pull/14675#discussion_r1957081225
########## datafusion/functions/src/string/uuid.rs: ########## @@ -87,7 +88,13 @@ impl ScalarUDFImpl for UuidFunc { if !args.is_empty() { return internal_err!("{} function does not accept arguments", self.name()); } - let values = std::iter::repeat_with(|| Uuid::new_v4().to_string()).take(num_rows); + + // Generate random u128 values + let mut rng = rand::thread_rng(); + let mut randoms = vec![0u128; num_rows]; + rng.fill(&mut randoms[..]); + + let values = randoms.into_iter().map(|x| Uuid::from_u128(x).to_string()); Review Comment: I tried calling `Uuid::new_v4()` instead of `Uuid::from_u128` with thread_rng. The performance was the same as before this PR. I think the performance comes from not having to repeatedly call the rng for bytes. Instead, num_rows*36 bytes can be rng'ed at once. -- 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