-
- Downloads
[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(unionByName(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. Author: hyukjinkwon <gurwls223@gmail.com> Closes #19105 from HyukjinKwon/unionByName-r-python.
Showing
- R/pkg/NAMESPACE 1 addition, 0 deletionsR/pkg/NAMESPACE
- R/pkg/R/DataFrame.R 36 additions, 2 deletionsR/pkg/R/DataFrame.R
- R/pkg/R/generics.R 4 additions, 0 deletionsR/pkg/R/generics.R
- R/pkg/tests/fulltests/test_sparkSQL.R 8 additions, 1 deletionR/pkg/tests/fulltests/test_sparkSQL.R
- python/pyspark/sql/dataframe.py 25 additions, 3 deletionspython/pyspark/sql/dataframe.py
Loading
Please register or sign in to comment