thisisnic commented on a change in pull request #10624:
URL: https://github.com/apache/arrow/pull/10624#discussion_r664603120



##########
File path: r/R/dplyr-functions.R
##########
@@ -280,6 +280,45 @@ nse_funcs$str_trim <- function(string, side = c("both", 
"left", "right")) {
   Expression$create(trim_fun, string)
 }
 
+nse_funcs$substr <- function(string, start, stop) {
+  assert_that(
+    length(start) == 1,
+    msg = "Start of length != 1 not supported in Arrow"
+  )
+  assert_that(
+    length(end) == 1,
+    msg = "End of length != 1 not supported in Arrow"
+  )
+
+  if (start > stop) {
+    start <- 0
+    stop <- 0
+  } else {
+    start <- max(0, start - 1)
+    stop <- max(0, stop)
+    start_stop <- c(min(start, stop), max(start, stop))
+    start <- start_stop[1]
+    stop <- start_stop[2]
+  }

Review comment:
       Sorry, I'm still confused, could you explain a bit more? Just that it 
seems a bit dangerous to be swapping parameters around unless we have reason 
to, right?




-- 
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-unsubscr...@arrow.apache.org

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


Reply via email to