drtconway opened a new issue, #16366:
URL: https://github.com/apache/datafusion/issues/16366

   ### Is your feature request related to a problem or challenge?
   
   Thanks for an awesome platform! I'm really loving it!
   
   In R `pmin` and `pmax` do row-wise min and max respectively. They're 
reasonably verbose to replicate, and probably much less efficient than a direct 
implementation. At the moment, I use the following code to achieve the same 
effect:
   
   ```rust
   pub fn ifelse(cond: Expr, then: Expr, otherwise: Expr) -> 
datafusion::common::Result<Expr> {
       case(cond)
           .when(lit(true), then)
           .when(lit(false), otherwise)
           .end()
   }
   
   pub fn pmin(lhs: Expr, rhs: Expr) -> datafusion::common::Result<Expr> {
       ifelse(lhs.clone().lt_eq(rhs.clone()), lhs, rhs)
   }
   
   pub fn pmax(lhs: Expr, rhs: Expr) -> datafusion::common::Result<Expr> {
       ifelse(lhs.clone().gt_eq(rhs.clone()), lhs, rhs)
   }
   ```
   
   ### Describe the solution you'd like
   
   A direct, builtin implementation would be faster, and more concise, since it 
could support a signature:
   `fn pmin(lhs: Expr, rhs: Expr) -> Expr`.
   
   The `ifelse` function would be nice too (I like the R equivalent too!), but 
is a lower priority.
   
   ### Describe alternatives you've considered
   
   The above code works, and isn't too awful, but a direct implementation would 
be nicer.
   
   ### Additional context
   
   _No response_


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