Skip to content

Commit 3619fec

Browse files
committed
[SPARK-14142][SQL] Replace internal use of unionAll with union
## What changes were proposed in this pull request? unionAll has been deprecated in SPARK-14088. ## How was this patch tested? Should be covered by all existing tests. Author: Reynold Xin <[email protected]> Closes apache#11946 from rxin/SPARK-14142.
1 parent 13cbb2d commit 3619fec

File tree

21 files changed

+45
-45
lines changed

21 files changed

+45
-45
lines changed

python/pyspark/sql/dataframe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def repartition(self, numPartitions, *cols):
360360
361361
>>> df.repartition(10).rdd.getNumPartitions()
362362
10
363-
>>> data = df.unionAll(df).repartition("age")
363+
>>> data = df.union(df).repartition("age")
364364
>>> data.show()
365365
+---+-----+
366366
|age| name|
@@ -919,7 +919,7 @@ def union(self, other):
919919
This is equivalent to `UNION ALL` in SQL. To do a SQL-style set union
920920
(that does deduplication of elements), use this function followed by a distinct.
921921
"""
922-
return DataFrame(self._jdf.unionAll(other._jdf), self.sql_ctx)
922+
return DataFrame(self._jdf.union(other._jdf), self.sql_ctx)
923923

924924
@since(1.3)
925925
def unionAll(self, other):

python/pyspark/sql/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ def test_parquet_with_udt(self):
599599
point = df1.head().point
600600
self.assertEqual(point, PythonOnlyPoint(1.0, 2.0))
601601

602-
def test_unionAll_with_udt(self):
602+
def test_union_with_udt(self):
603603
from pyspark.sql.tests import ExamplePoint, ExamplePointUDT
604604
row1 = (1.0, ExamplePoint(1.0, 2.0))
605605
row2 = (2.0, ExamplePoint(3.0, 4.0))
@@ -608,7 +608,7 @@ def test_unionAll_with_udt(self):
608608
df1 = self.sqlCtx.createDataFrame([row1], schema)
609609
df2 = self.sqlCtx.createDataFrame([row2], schema)
610610

611-
result = df1.unionAll(df2).orderBy("label").collect()
611+
result = df1.union(df2).orderBy("label").collect()
612612
self.assertEqual(
613613
result,
614614
[

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/dsl/package.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ package object dsl {
280280

281281
def intersect(otherPlan: LogicalPlan): LogicalPlan = Intersect(logicalPlan, otherPlan)
282282

283-
def unionAll(otherPlan: LogicalPlan): LogicalPlan = Union(logicalPlan, otherPlan)
283+
def union(otherPlan: LogicalPlan): LogicalPlan = Union(logicalPlan, otherPlan)
284284

285285
def generate(
286286
generator: Generator,

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisErrorSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class AnalysisErrorSuite extends AnalysisTest {
250250

251251
errorTest(
252252
"union with unequal number of columns",
253-
testRelation.unionAll(testRelation2),
253+
testRelation.union(testRelation2),
254254
"union" :: "number of columns" :: testRelation2.output.length.toString ::
255255
testRelation.output.length.toString :: Nil)
256256

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AnalysisSuite extends AnalysisTest {
3232
val plan = (1 to 100)
3333
.map(_ => testRelation)
3434
.fold[LogicalPlan](testRelation) { (a, b) =>
35-
a.select(UnresolvedStar(None)).select('a).unionAll(b.select(UnresolvedStar(None)))
35+
a.select(UnresolvedStar(None)).select('a).union(b.select(UnresolvedStar(None)))
3636
}
3737

3838
assertAnalysisSuccess(plan)

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/PruneFiltersSuite.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ class PruneFiltersSuite extends PlanTest {
6060

6161
val query =
6262
tr1.where('a.attr > 10)
63-
.unionAll(tr2.where('d.attr > 10)
64-
.unionAll(tr3.where('g.attr > 10)))
63+
.union(tr2.where('d.attr > 10)
64+
.union(tr3.where('g.attr > 10)))
6565
val queryWithUselessFilter = query.where('a.attr > 10)
6666

6767
val optimized = Optimize.execute(queryWithUselessFilter.analyze)

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/plans/ConstraintPropagationSuite.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ class ConstraintPropagationSuite extends SparkFunSuite {
109109

110110
assert(tr1
111111
.where('a.attr > 10)
112-
.unionAll(tr2.where('e.attr > 10)
113-
.unionAll(tr3.where('i.attr > 10)))
112+
.union(tr2.where('e.attr > 10)
113+
.union(tr3.where('i.attr > 10)))
114114
.analyze.constraints.isEmpty)
115115

116116
verifyConstraints(tr1
117117
.where('a.attr > 10)
118-
.unionAll(tr2.where('d.attr > 10)
119-
.unionAll(tr3.where('g.attr > 10)))
118+
.union(tr2.where('d.attr > 10)
119+
.union(tr3.where('g.attr > 10)))
120120
.analyze.constraints,
121121
ExpressionSet(Seq(resolveColumn(tr1, "a") > 10,
122122
IsNotNull(resolveColumn(tr1, "a")))))

sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/memory.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ case class MemoryStream[A : Encoder](id: Int, sqlContext: SQLContext)
9797
s"MemoryBatch [$startOrdinal, $endOrdinal]: ${newBlocks.flatMap(_.collect()).mkString(", ")}")
9898
newBlocks
9999
.map(_.toDF())
100-
.reduceOption(_ unionAll _)
100+
.reduceOption(_ union _)
101101
.getOrElse {
102102
sys.error("No data selected!")
103103
}

sql/core/src/test/scala/org/apache/spark/sql/CachedTableSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ class CachedTableSuite extends QueryTest with SQLTestUtils with SharedSQLContext
363363
}
364364

365365
test("A cached table preserves the partitioning and ordering of its cached SparkPlan") {
366-
val table3x = testData.unionAll(testData).unionAll(testData)
366+
val table3x = testData.union(testData).union(testData)
367367
table3x.registerTempTable("testData3x")
368368

369369
sql("SELECT key, value FROM testData3x ORDER BY key").registerTempTable("orderedTable")

sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class DataFrameStatSuite extends QueryTest with SharedSQLContext {
5757
val splits = data.randomSplit(Array[Double](1, 2, 3), seed)
5858
assert(splits.length == 3, "wrong number of splits")
5959

60-
assert(splits.reduce((a, b) => a.unionAll(b)).sort("id").collect().toList ==
60+
assert(splits.reduce((a, b) => a.union(b)).sort("id").collect().toList ==
6161
data.collect().toList, "incomplete or wrong split")
6262

6363
val s = splits.map(_.count())

0 commit comments

Comments
 (0)