AlenkaF commented on code in PR #12855:
URL: https://github.com/apache/arrow/pull/12855#discussion_r853998157


##########
r/R/dplyr-funcs-datetime.R:
##########
@@ -376,6 +376,21 @@ register_bindings_duration_helpers <- function() {
   register_binding("dyears", function(x = 1) {
     make_duration(x * 31557600, "s")
   })
+  register_binding("dseconds", function(x = 1) {
+    make_duration(x, "s")
+  })
+  register_binding("dmilliseconds", function(x = 1) {
+    make_duration(x, "ms")
+  })
+  register_binding("dmicroseconds", function(x = 1) {
+    make_duration(x, "us")
+  })
+  register_binding("dnanoseconds", function(x = 1) {
+    make_duration(x, "ns")
+  })
+  register_binding("dpicoseconds", function(x = 1) {
+    abort("Duration in picoseconds not supported in Arrow.")
+  })

Review Comment:
   I am a bit stuck, any pointers where to look for what's wrong in this try of 
the mapping?
   
   ```R
   .helpers_function_map <- list(
     "dminutes" = c(60, "s"),
     "dhours" = c(3600, "s"),
     "ddays" = c(86400, "s"),
     "dweeks" = c(604800, "s"),
     "dmonths" = c(2629800, "s"),
     "ydyears" = c(31557600, "s"),
     "dseconds" = c(1, "s"),
     "dmilliseconds" = c(1, "ms"),
     "dmicroseconds" = c(1, "us"),
     "dnanoseconds" = c(1, "ns")
   )
   make_duration <- function(x, unit) {
     x <- build_expr("cast", x, options = cast_options(to_type = int64()))
     x$cast(duration(unit))
   }
   register_bindings_duration_helpers <- function() {
     duration_helpers_map_factory <- function(value, unit) {
       force(value)
       force(unit)
       function(x = 1) make_duration(x * value, unit)
     }
   
     for (name in names(.helpers_function_map)){
       register_binding(
         name,
         duration_helpers_map_factory(
           .helpers_function_map[[name]][1],
           .helpers_function_map[[name]][2]
         )
       )
     }
   
     register_binding("dpicoseconds", function(x = 1) {
       abort("Duration in picoseconds not supported in Arrow.")
     })
   }
   ```



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

Reply via email to