MohamedAbdeen21 commented on code in PR #10832:
URL: https://github.com/apache/datafusion/pull/10832#discussion_r1632311422


##########
datafusion/expr/src/expr.rs:
##########
@@ -1133,14 +1133,23 @@ impl Expr {
     }
 
     /// Return `self AS name` alias expression
+    /// Removes existing Alias if exists
+    ///
+    /// # Example
+    /// ```
+    /// # use datafusion_expr::col;
+    /// // `foo as "bar" as "baz"` is resolved to `foo as "baz"`
+    /// let expr = col("foo").alias("bar").alias("baz");
+    /// assert_eq!(expr, col("foo").alias("baz"));
+    /// ```
     pub fn alias(self, name: impl Into<String>) -> Expr {
         match self {
             Expr::Sort(Sort {
                 expr,
                 asc,
                 nulls_first,
             }) => Expr::Sort(Sort::new(Box::new(expr.alias(name)), asc, 
nulls_first)),
-            _ => Expr::Alias(Alias::new(self, None::<&str>, name.into())),
+            _ => Expr::Alias(Alias::new(self.unalias(), None::<&str>, 
name.into())),

Review Comment:
   It's not a breaking change, but I'm fine with deferring it.



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

Reply via email to