GitHub user HyukjinKwon opened a pull request:

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

    [SPARK-21897][PYTHON][R] Add unionByName API to DataFrame in Python and R

    ## What changes were proposed in this pull request?
    
    This PR proposes to add a wrapper for `unionByName` API to R and Python as 
well.
    
    **Python**
    
    ```python
    df1 = spark.createDataFrame([[1, 2, 3]], ["col0", "col1", "col2"])
    df2 = spark.createDataFrame([[4, 5, 6]], ["col1", "col2", "col0"])
    df1.unionByName(df2).show()
    ```
    
    ```
    +----+----+----+
    |col0|col1|col3|
    +----+----+----+
    |   1|   2|   3|
    |   6|   4|   5|
    +----+----+----+
    ```
    
    **R**
    
    ```R
    df1 <- select(createDataFrame(mtcars), "carb", "am", "gear")
    df2 <- select(createDataFrame(mtcars), "am", "gear", "carb")
    head(union(limit(df1, 2), limit(df2, 2)))
    ```
    
    ```
      carb am gear
    1    4  1    4
    2    4  1    4
    3    4  1    4
    4    4  1    4
    ```
    
    ## How was this patch tested?
    
    Doctests for Python and unit test added in `test_sparkSQL.R` for R.


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

    $ git pull https://github.com/HyukjinKwon/spark unionByName-r-python

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

    https://github.com/apache/spark/pull/19105.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 #19105
    
----
commit 058feeb4a56fdb81566de90cd7a5bcbe03bc5486
Author: hyukjinkwon <[email protected]>
Date:   2017-09-02T00:53:54Z

    Add unionByName API to DataFrame in Python and R

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to