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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]