Commits


Neal Richardson authored and GitHub committed f29be8020e8
ARROW-18203: [R] Refactor to remove unnecessary uses of build_expr (#14553) This PR removes all uses of `build_expr()` not related to operators (logical and arithmetic functions), renames it to `Expression$op()` to be explicit that that's what it is for, and removes handling from the function that would allow it to be called with anything that is not in the operators list. Most places where the bindings code was using `build_expr()` were unnecessary because they were unary functions so there are no types to align. `cast` was a big part of this. Other places were switched to use `call_binding()`. The helper function I added in the previous PR to cast Scalars to the common type of the Expression(s) in the arguments has been renamed to `cast_scalars_to_common_type()`. It is now used only in `Expression$op()`, `ifelse`, `pmin`, and `pmax`. The docs for `register_binding()` have been updated to reflect how you can use this function if it is appropriate. In this PR I also split out the UDF code to udf.R and moved the operator mappings to dplyr-funcs.simple.R. There is one behavior change as a result of this refactor: when the input is a Scalar (or R vector turned into a Scalar), the casting happens on the Scalar eagerly, not lazily as an Expression--meaning that the call to `filter()` or `mutate()` errors immediately and it doesn't wait to error until `collect()`. This only affected a few datetime tests for bad input. Authored-by: Neal Richardson <neal.p.richardson@gmail.com> Signed-off-by: Neal Richardson <neal.p.richardson@gmail.com>