andygrove commented on code in PR #4234:
URL: https://github.com/apache/arrow-datafusion/pull/4234#discussion_r1025837127
##########
datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs:
##########
@@ -760,6 +766,29 @@ impl<'a, S: SimplifyInfo> ExprRewriter for Simplifier<'a,
S> {
},
},
+ // unfold the expression round(source, n)
+ Expr::ScalarFunction {
+ fun: BuiltinScalarFunction::Round,
+ args,
Review Comment:
> Why is that? Could you please give an example?
Sure. Taking Dask SQL as an example, we would want to translate `round(a,
b)` to a call to a Python function to perform the rounding (perhaps in numpy).
With this PR, the logical plan now has a complex expression that is specific to
the DataFusion implementation. Dask SQL would have to undo the `pow` logic here
to get back to the original parameters to `round` so that it can pass them to
numpy.
```
Projection: round(CAST(test.column_1 AS Float64) * Float64(0.01)) /
Float64(0.01) AS round(test.column_1,Int64(-2))
```
--
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]