alamb commented on code in PR #11614: URL: https://github.com/apache/datafusion/pull/11614#discussion_r1688478700
########## 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"); + } + + drop(unique_field_names_set); Review Comment: seems reasonable -- another way to do this is in a scope (enclosed with `{` and `}` ```rust { // 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"); } ``` -- 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