GitHub user HyukjinKwon opened a pull request:

    https://github.com/apache/spark/pull/21142

    [SPARK-24069][R] Add array_min / array_max functions

    ## What changes were proposed in this pull request?
    
    This PR proposes to add array_max and array_min in R side too.
    
    array_max:
    
    ```r
    df <- createDataFrame(cbind(model = rownames(mtcars), mtcars))
    mutated <- mutate(df, v1 = create_array(df$gear, df$am, df$carb))
    head(select(mutated, array_max(mutated$v1)))
    ```
    
    ```
      array_max(v1)
    1             4
    2             4
    3             4
    4             3
    5             3
    6             3
    ```
    
    array_min:
    
    ```r
    df <- createDataFrame(cbind(model = rownames(mtcars), mtcars))
    mutated <- mutate(df, v1 = create_array(df$mpg, df$cyl, df$hp))
    head(select(mutated, array_min(mutated$v1)))
    ```
    
    ```
      array_min(v1)
    1             6
    2             6
    3             4
    4             6
    5             8
    6             6
    ```
    
    ## How was this patch tested?
    
    Unit tests were added in `R/pkg/tests/fulltests/test_sparkSQL.R` and 
manually tested. Documentation was manually built and verified.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/HyukjinKwon/spark sparkr_array_min_array_max

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/21142.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #21142
    
----

----


---

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

Reply via email to