alamb commented on code in PR #11614: URL: https://github.com/apache/datafusion/pull/11614#discussion_r1688480974
########## datafusion/functions/src/core/named_struct.rs: ########## @@ -57,6 +57,15 @@ fn named_struct_expr(args: &[ColumnarValue]) -> Result<ColumnarValue> { .into_iter() .unzip(); + // Check to enforce the uniqueness of struct field name + let unique_field_names_set = names.iter().collect::<HashSet<_>>(); + + if unique_field_names_set.len() != names.len() { + return exec_err!("named_struct requires unique field names"); Review Comment: It might be nice if you could structure the code so it gave one of the duplicated names. Maybe something like ```rust let mut unique_field_names_set = HashSet::new(); for name in names { if unique_field_names_set.contains(name) { return exec_err!("named_struct requires unique field names. {name} repeated"); } unique_field_names_set.insert(name) } ``` -- 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