dragosmg commented on code in PR #12855:
URL: https://github.com/apache/arrow/pull/12855#discussion_r849416453
##########
r/R/dplyr-funcs-datetime.R:
##########
@@ -323,6 +323,37 @@ register_bindings_duration <- function() {
build_expr("cast", x, options = cast_options(to_type = duration(unit =
"s")))
})
+ register_binding("dseconds", function(x = 1) {
+ if (!inherits(x, "Expression")) {
+ x <- Expression$scalar(x)
+ }
+ dseconds_int64 <- Expression$create("cast", x, options =
cast_options(to_type = int64()))
Review Comment:
You could replace `Expression$create()` with `build_expr()` which then
allows you to get rid of the `if (!inherits(x, "Expression"))` logic.
`build_expr()` is in fact `Expression$create()` plus an automatic conversion
of R objects to Scalar.
##########
r/R/dplyr-funcs-datetime.R:
##########
@@ -323,6 +323,37 @@ register_bindings_duration <- function() {
build_expr("cast", x, options = cast_options(to_type = duration(unit =
"s")))
})
+ register_binding("dseconds", function(x = 1) {
+ if (!inherits(x, "Expression")) {
+ x <- Expression$scalar(x)
+ }
+ dseconds_int64 <- Expression$create("cast", x, options =
cast_options(to_type = int64()))
Review Comment:
You could replace `Expression$create()` with `build_expr()` which then
allows you to get rid of the `if (!inherits(x, "Expression"))` logic.
`build_expr()` is in fact `Expression$create()` plus an automatic conversion
of R objects to Scalar.
--
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]