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/05/12 10:55:28 UTC

[GitHub] [arrow] thisisnic commented on a diff in pull request #13118: ARROW-16394: [R] Implement lubridate's parsers with year, month and date components

thisisnic commented on code in PR #13118:
URL: https://github.com/apache/arrow/pull/13118#discussion_r871237912


##########
r/R/dplyr-funcs-datetime.R:
##########
@@ -518,6 +518,28 @@ register_bindings_datetime_parsers <- function() {
 
     coalesce_output <- build_expr("coalesce", args = parse_attempt_expressions)
 
-    build_expr("assume_timezone", coalesce_output, options = list(timezone = tz))
+    if (!is.null(tz)) {

Review Comment:
   Please can you add a brief comment about why we need this logic here?



##########
r/R/dplyr-funcs-datetime.R:
##########
@@ -518,6 +518,28 @@ register_bindings_datetime_parsers <- function() {
 
     coalesce_output <- build_expr("coalesce", args = parse_attempt_expressions)
 
-    build_expr("assume_timezone", coalesce_output, options = list(timezone = tz))
+    if (!is.null(tz)) {
+      build_expr("assume_timezone", coalesce_output, options = list(timezone = tz))
+    } else {
+      coalesce_output
+    }
+
   })
+
+  ymd_parser_vec <- c("ymd", "ydm", "mdy", "myd", "dmy", "dym")
+
+  ymd_parser_map_factory <- function(order) {
+    force(order)

Review Comment:
   Why do we need to call `force()` here?



##########
r/R/dplyr-funcs-datetime.R:
##########
@@ -518,6 +518,28 @@ register_bindings_datetime_parsers <- function() {
 
     coalesce_output <- build_expr("coalesce", args = parse_attempt_expressions)
 
-    build_expr("assume_timezone", coalesce_output, options = list(timezone = tz))
+    if (!is.null(tz)) {
+      build_expr("assume_timezone", coalesce_output, options = list(timezone = tz))
+    } else {
+      coalesce_output
+    }
+
   })
+
+  ymd_parser_vec <- c("ymd", "ydm", "mdy", "myd", "dmy", "dym")
+
+  ymd_parser_map_factory <- function(order) {
+    force(order)
+    function(x, tz = NULL) {
+      parse_x <- call_binding("parse_date_time", x, order, tz)
+      if (is.null(tz)) {
+        parse_x <- parse_x$cast(date32())

Review Comment:
   Again, just needs a brief comment here about why we have to cast in this case.



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