You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/04/11 18:15:51 UTC

[GitHub] [arrow] jonkeane commented on a diff in pull request #12707: ARROW-14810 [R] Implement bindings for lubridate's `date_decimal()` and `decimal_date()`

jonkeane commented on code in PR #12707:
URL: https://github.com/apache/arrow/pull/12707#discussion_r847609979


##########
r/R/dplyr-funcs-datetime.R:
##########
@@ -300,6 +314,34 @@ register_bindings_duration <- function() {
 
     build_expr("cast", x, options = cast_options(to_type = duration(unit = "s")))
   })
+  register_binding("decimal_date", function(date) {
+    y <- build_expr("year", date)
+    start <- call_binding("make_datetime", year = y, tz = "UTC")
+    sofar <- call_binding("difftime", date, start, units = "secs")
+    total <- call_binding(
+      "if_else",
+      build_expr("is_leap_year", date),
+      call_binding("as.integer64", 31622400L),  # number of seconds in a leap year (366 days)
+      call_binding("as.integer64", 31536000L)   # number of seconds in a regular year (365 days)

Review Comment:
   I don't have any reason to believe this would be different at larger scales, but for benchmarks like these we probably should use larger sets of data than a handful of rows. It depends on what we're looking at, but 10k-100k rows is more reasonable for something like this



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org