alamb commented on code in PR #10405:
URL: https://github.com/apache/datafusion/pull/10405#discussion_r1592578860


##########
datafusion/expr/src/expr.rs:
##########
@@ -1087,13 +1087,60 @@ impl Expr {
     }
 
     /// Remove an alias from an expression if one exists.
+    ///
+    /// If the expression is not an alias, the expression is returned 
unchanged.
+    /// This method does not remove aliases from nested expressions.
+    ///
+    /// # Example
+    /// ```
+    /// # use datafusion_expr::col;
+    /// // `foo as "bar"` is unaliased to `foo`
+    /// let expr = col("foo").alias("bar");
+    /// assert_eq!(expr.unalias(), col("foo"));
+    ///
+    /// // `foo as "bar" + baz` is not unaliased
+    /// let expr = col("foo").alias("bar") + col("baz");
+    /// assert_eq!(expr.clone().unalias(), expr);
+    ///
+    /// // `foo as "bar" as "baz" is unalaised to foo as "bar"
+    /// let expr = col("foo").alias("bar").alias("baz");
+    /// assert_eq!(expr.unalias(), col("foo").alias("bar"));
+    /// ```
     pub fn unalias(self) -> Expr {
         match self {
             Expr::Alias(alias) => *alias.expr,
             _ => self,
         }
     }
 
+    /// Recursively potentially multiple aliases from an expression.

Review Comment:
   This is `trim_expr` renamed and with examples



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