Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/20464#discussion_r165584627
  
    --- Diff: R/pkg/R/column.R ---
    @@ -169,7 +169,7 @@ setMethod("alias",
     #' @note substr since 1.4.0
     setMethod("substr", signature(x = "Column"),
               function(x, start, stop) {
    -            jc <- callJMethod(x@jc, "substr", as.integer(start - 1), 
as.integer(stop - start + 1))
    +            jc <- callJMethod(x@jc, "substr", as.integer(start), 
as.integer(stop - start + 1))
    --- End diff --
    
    > is there a way to make the behavior the same before this change for any 
caller calling substr with common index like 0
    
    Should we keep the behavior when calling substr with 0 as start index?
    
    ```R
    > df <- createDataFrame(list(list(a="abcdef")))
    > collect(select(df, substr(df$a, 0, 5)))
      substring(a, -1, 6)
    1                   f
    > substr("abcdef", 0, 5)
    [1] "abcde"
    ```
    
    I think the previous behavior is pretty unreasonable..


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to