alamb opened a new issue #1718:
URL: https://github.com/apache/arrow-datafusion/issues/1718
**Is your feature request related to a problem or challenge? Please describe
what you are trying to do.**
I am trying to programatically create `Expr`s that represent function calls,
for example `to_timetsamp(x, 4)` or something
To do so today you have to do something like this (from
simplify_expressions.rs) which is 🤮
```rust
// to_timestamp("2020-09-08T12:00:00+00:00")
let expr = Expr::ScalarFunction {
args: vec![lit("2020-09-08T12:00:00+00:00")],
fun: BuiltinScalarFunction::ToTimestamp,
};
```
**Describe the solution you'd like**
I would like to write code like this
```rust
// to_timestamp("2020-09-08T12:00:00+00:00") -->
timestamp(1599566400000000000i64)
let expr = call("to_timestamp",
vec![lit("2020-09-08T12:00:00+00:00")])
.unwrap();
```rust
Perhap with an api like this
```rust
/// Calls a named built in function
///
/// ```
/// use datafusion::logical_plan::*;
///
/// // create the expression sin(x) < 0.2
/// let expr = call("sin", vec![col("x")]).unwrap().lt(lit(0.2));
///
/// ```
pub fn call(name: impl AsRef<str>, args: Vec<Expr>) -> Result<Expr> {
...
}
```
Note you can lookup a `str` to scalar function by name with something like:
```rust
let fun = name.as_ref().parse::<BuiltinScalarFunction>()?;
```
**Additional context**
There are a bunch of this nonsense in `simplify_expression.rs` which could
be cleaned up
--
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]