jackwener commented on code in PR #9154:
URL: https://github.com/apache/arrow-datafusion/pull/9154#discussion_r1483092941


##########
datafusion/expr/src/logical_plan/builder.rs:
##########
@@ -1124,7 +1124,28 @@ impl LogicalPlanBuilder {
         )?))
     }
 }
-
+pub fn change_redundant_column(fields: Vec<DFField>) -> Vec<DFField> {
+    let mut name_map = HashMap::new();
+    fields
+        .into_iter()
+        .map(|field| {
+            if !name_map.contains_key(field.name()) {
+                name_map.insert(field.name().to_string(), 0);
+                field
+            } else {
+                let cur_cnt = &name_map.get(field.name());
+                let name = field.name().to_string() + ":" + 
&cur_cnt.unwrap().to_string();
+                name_map.insert(field.name().to_string(), cur_cnt.unwrap() + 
1);
+                DFField::new(
+                    field.qualifier().cloned(),
+                    &name,
+                    field.data_type().clone(),
+                    field.is_nullable(),
+                )
+            }

Review Comment:
   ```suggestion
               let counter = 
name_map.entry(field.name().to_string()).or_insert(0);
               *counter += 1;
               if *counter > 1 {
                   let new_name = format!("{}:{}", field.name(), counter);
                   DFField::new(
                       field.qualifier().cloned(),
                       &new_name,
                       field.data_type().clone(),
                       field.is_nullable(),
                   )
               } else {
                   field
               }
   ```



-- 
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]

Reply via email to