You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/12/20 08:41:24 UTC

[GitHub] [arrow-datafusion] Dandandan opened a new issue #1468: Remove `Alias` from `Expr`

Dandandan opened a new issue #1468:
URL: https://github.com/apache/arrow-datafusion/issues/1468


   **Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
   
   Currently a named expression / alias can be encoded by wrapping an existing `Expr` in an `Expr::Alias`.
   
   However, this has some side effects:
   
   * We can encode expressions that don't make sense, such as `(1 + 1 AS x) AS y` or `(1 AS X) + (1 AS Y)` (in SQL it's disallowed by the parser, but it's just to show it is possible to do this in the DataFrame API or the raw API. In dataframes we could do things like `expr.alias("x").alias("y")`.
   
   * Code dealing with `Expr` always have to deal with the `Alias` case, even when it doesn't care. This could lead to more complex code or even subtle bugs.
   
   **Describe the solution you'd like**
   
   * Create a new struct, `NamedExpr` that is used to refer to a named expression
   
   ```rust
   NamedExpr {
       /// Alias or generated name
       name: String,
       /// The expression
       expr: Expr,
   }
   ```
   
   * The `NamedExpr` now can be used inside projections, aggregates, etc.
   
   * The function `alias` on `DataFrame` should return an `NamedExpr` 
   
   * Add an `impl From<Expr> for NamedExpr` that generates a name.
   
   * Some functions can accept Into<NamedExpr> to keep being ergonomic to use.
   
   **Describe alternatives you've considered**
   
   **Additional context**
   


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] houqp commented on issue #1468: Remove `Alias` from `Expr`

Posted by GitBox <gi...@apache.org>.
houqp commented on issue #1468:
URL: https://github.com/apache/arrow-datafusion/issues/1468#issuecomment-1000687342


   It's not entirely clear to me how we are going to propagate it through out the code base. But if we can pull it off, that would make the code more readable and maintainable for sure :+1: 


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] alamb commented on issue #1468: Remove `Alias` from `Expr`

Posted by GitBox <gi...@apache.org>.
alamb commented on issue #1468:
URL: https://github.com/apache/arrow-datafusion/issues/1468#issuecomment-998826575


   I think `NamedExpr` sounds like a great idea, personally. 👍 


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] Dandandan commented on issue #1468: Remove `Alias` from `Expr`

Posted by GitBox <gi...@apache.org>.
Dandandan commented on issue #1468:
URL: https://github.com/apache/arrow-datafusion/issues/1468#issuecomment-997713423


   FYI @alamb @houqp 


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] xudong963 commented on issue #1468: Remove `Alias` from `Expr`

Posted by GitBox <gi...@apache.org>.
xudong963 commented on issue #1468:
URL: https://github.com/apache/arrow-datafusion/issues/1468#issuecomment-998853724


   Make sense to me @Dandandan 


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org