hareshkh commented on code in PR #19856:
URL: https://github.com/apache/datafusion/pull/19856#discussion_r2811955108


##########
datafusion/substrait/src/logical_plan/consumer/utils.rs:
##########
@@ -396,9 +424,22 @@ impl NameTracker {
         &mut self,
         expr: Expr,
     ) -> datafusion::common::Result<Expr> {
-        match self.get_unique_name(expr.name_for_alias()?) {
-            (_, NameTrackerStatus::NeverSeen) => Ok(expr),
-            (name, NameTrackerStatus::SeenBefore) => Ok(expr.alias(name)),
+        if !self.would_conflict(&expr) {
+            self.insert(&expr);
+            return Ok(expr);
+        }
+
+        // Name collision - need to generate a unique alias
+        let schema_name = expr.schema_name().to_string();
+        let mut counter = 0;
+        loop {
+            let candidate_name = format!("{schema_name}__temp__{counter}");
+            let candidate_expr = expr.clone().alias(candidate_name.clone());

Review Comment:
   This clone could be avoided by checking in the hashsets directly



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

Reply via email to