Skip to content

Commit ce6e369

Browse files
committed
Fixed tests.
1 parent 6095fed commit ce6e369

17 files changed

+77
-78
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ class ColumnExpressionSuite extends QueryTest {
2828
import org.apache.spark.sql.TestData._
2929

3030
test("single explode") {
31-
val df = Seq((1, Seq(1,2,3))).toDF("a", "intList")
31+
val df = Seq((1, Seq(1, 2, 3))).toDF("a", "intList")
3232
checkAnswer(
3333
df.select(explode('intList)),
3434
Row(1) :: Row(2) :: Row(3) :: Nil)
3535
}
3636

3737
test("explode and other columns") {
38-
val df = Seq((1, Seq(1,2,3))).toDF("a", "intList")
38+
val df = Seq((1, Seq(1, 2, 3))).toDF("a", "intList")
3939

4040
checkAnswer(
4141
df.select($"a", explode('intList)),
@@ -45,13 +45,13 @@ class ColumnExpressionSuite extends QueryTest {
4545

4646
checkAnswer(
4747
df.select($"*", explode('intList)),
48-
Row(1, Seq(1,2,3), 1) ::
49-
Row(1, Seq(1,2,3), 2) ::
50-
Row(1, Seq(1,2,3), 3) :: Nil)
48+
Row(1, Seq(1, 2, 3), 1) ::
49+
Row(1, Seq(1, 2, 3), 2) ::
50+
Row(1, Seq(1, 2, 3), 3) :: Nil)
5151
}
5252

5353
test("aliased explode") {
54-
val df = Seq((1, Seq(1,2,3))).toDF("a", "intList")
54+
val df = Seq((1, Seq(1, 2, 3))).toDF("a", "intList")
5555

5656
checkAnswer(
5757
df.select(explode('intList).as('int)).select('int),
@@ -79,7 +79,7 @@ class ColumnExpressionSuite extends QueryTest {
7979
}
8080

8181
test("self join explode") {
82-
val df = Seq((1, Seq(1,2,3))).toDF("a", "intList")
82+
val df = Seq((1, Seq(1, 2, 3))).toDF("a", "intList")
8383
val exploded = df.select(explode('intList).as('i))
8484

8585
checkAnswer(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ class DataFrameAggregateSuite extends QueryTest {
148148
test("null count") {
149149
checkAnswer(
150150
testData3.groupBy('a).agg(count('b)),
151-
Seq(Row(1,0), Row(2, 1))
151+
Seq(Row(1, 0), Row(2, 1))
152152
)
153153

154154
checkAnswer(
155155
testData3.groupBy('a).agg(count('a + 'b)),
156-
Seq(Row(1,0), Row(2, 1))
156+
Seq(Row(1, 0), Row(2, 1))
157157
)
158158

159159
checkAnswer(

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class DataFrameSuite extends QueryTest {
5959
}
6060

6161
test("rename nested groupby") {
62-
val df = Seq((1,(1,1))).toDF()
62+
val df = Seq((1, (1, 1))).toDF()
6363

6464
checkAnswer(
6565
df.groupBy("_1").agg(sum("_2._1")).toDF("key", "total"),
@@ -211,23 +211,23 @@ class DataFrameSuite extends QueryTest {
211211
test("global sorting") {
212212
checkAnswer(
213213
testData2.orderBy('a.asc, 'b.asc),
214-
Seq(Row(1,1), Row(1,2), Row(2,1), Row(2,2), Row(3,1), Row(3,2)))
214+
Seq(Row(1, 1), Row(1, 2), Row(2, 1), Row(2, 2), Row(3, 1), Row(3, 2)))
215215

216216
checkAnswer(
217217
testData2.orderBy(asc("a"), desc("b")),
218-
Seq(Row(1,2), Row(1,1), Row(2,2), Row(2,1), Row(3,2), Row(3,1)))
218+
Seq(Row(1, 2), Row(1, 1), Row(2, 2), Row(2, 1), Row(3, 2), Row(3, 1)))
219219

220220
checkAnswer(
221221
testData2.orderBy('a.asc, 'b.desc),
222-
Seq(Row(1,2), Row(1,1), Row(2,2), Row(2,1), Row(3,2), Row(3,1)))
222+
Seq(Row(1, 2), Row(1, 1), Row(2, 2), Row(2, 1), Row(3, 2), Row(3, 1)))
223223

224224
checkAnswer(
225225
testData2.orderBy('a.desc, 'b.desc),
226-
Seq(Row(3,2), Row(3,1), Row(2,2), Row(2,1), Row(1,2), Row(1,1)))
226+
Seq(Row(3, 2), Row(3, 1), Row(2, 2), Row(2, 1), Row(1, 2), Row(1, 1)))
227227

228228
checkAnswer(
229229
testData2.orderBy('a.desc, 'b.asc),
230-
Seq(Row(3,1), Row(3,2), Row(2,1), Row(2,2), Row(1,1), Row(1,2)))
230+
Seq(Row(3, 1), Row(3, 2), Row(2, 1), Row(2, 2), Row(1, 1), Row(1, 2)))
231231

232232
checkAnswer(
233233
arrayData.toDF().orderBy('data.getItem(0).asc),
@@ -331,7 +331,7 @@ class DataFrameSuite extends QueryTest {
331331
checkAnswer(
332332
df,
333333
testData.collect().toSeq)
334-
assert(df.schema.map(_.name) === Seq("key","value"))
334+
assert(df.schema.map(_.name) === Seq("key", "value"))
335335
}
336336

337337
test("withColumnRenamed") {
@@ -364,24 +364,24 @@ class DataFrameSuite extends QueryTest {
364364

365365
test("describe") {
366366
val describeTestData = Seq(
367-
("Bob", 16, 176),
367+
("Bob", 16, 176),
368368
("Alice", 32, 164),
369369
("David", 60, 192),
370-
("Amy", 24, 180)).toDF("name", "age", "height")
370+
("Amy", 24, 180)).toDF("name", "age", "height")
371371

372372
val describeResult = Seq(
373-
Row("count", "4", "4"),
374-
Row("mean", "33.0", "178.0"),
375-
Row("stddev", "16.583123951777", "10.0"),
376-
Row("min", "16", "164"),
377-
Row("max", "60", "192"))
373+
Row("count", "4", "4"),
374+
Row("mean", "33.0", "178.0"),
375+
Row("stddev", "16.583123951777", "10.0"),
376+
Row("min", "16", "164"),
377+
Row("max", "60", "192"))
378378

379379
val emptyDescribeResult = Seq(
380-
Row("count", "0", "0"),
381-
Row("mean", null, null),
382-
Row("stddev", null, null),
383-
Row("min", null, null),
384-
Row("max", null, null))
380+
Row("count", "0", "0"),
381+
Row("mean", null, null),
382+
Row("stddev", null, null),
383+
Row("min", null, null),
384+
Row("max", null, null))
385385

386386
def getSchemaAsSeq(df: DataFrame): Seq[String] = df.schema.map(_.name)
387387

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ class JoinSuite extends QueryTest with BeforeAndAfterEach {
167167
val y = testData2.where($"a" === 1).as("y")
168168
checkAnswer(
169169
x.join(y).where($"x.a" === $"y.a"),
170-
Row(1,1,1,1) ::
171-
Row(1,1,1,2) ::
172-
Row(1,2,1,1) ::
173-
Row(1,2,1,2) :: Nil
170+
Row(1, 1, 1, 1) ::
171+
Row(1, 1, 1, 2) ::
172+
Row(1, 2, 1, 1) ::
173+
Row(1, 2, 1, 2) :: Nil
174174
)
175175
}
176176

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ListTablesSuite extends QueryTest with BeforeAndAfter {
2828
import org.apache.spark.sql.test.TestSQLContext.implicits._
2929

3030
val df =
31-
sparkContext.parallelize((1 to 10).map(i => (i,s"str$i"))).toDF("key", "value")
31+
sparkContext.parallelize((1 to 10).map(i => (i, s"str$i"))).toDF("key", "value")
3232

3333
before {
3434
df.registerTempTable("ListTablesSuiteTable")

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
5353
}
5454

5555
test("self join with aliases") {
56-
Seq(1,2,3).map(i => (i, i.toString)).toDF("int", "str").registerTempTable("df")
56+
Seq(1, 2, 3).map(i => (i, i.toString)).toDF("int", "str").registerTempTable("df")
5757

5858
checkAnswer(
5959
sql(
@@ -76,7 +76,7 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
7676
}
7777

7878
test("self join with alias in agg") {
79-
Seq(1,2,3)
79+
Seq(1, 2, 3)
8080
.map(i => (i, i.toString))
8181
.toDF("int", "str")
8282
.groupBy("str")
@@ -113,7 +113,7 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
113113
test("SPARK-4625 support SORT BY in SimpleSQLParser & DSL") {
114114
checkAnswer(
115115
sql("SELECT a FROM testData2 SORT BY a"),
116-
Seq(1, 1, 2 ,2 ,3 ,3).map(Row(_))
116+
Seq(1, 1, 2, 2, 3, 3).map(Row(_))
117117
)
118118
}
119119

@@ -354,7 +354,7 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
354354
test("left semi greater than predicate") {
355355
checkAnswer(
356356
sql("SELECT * FROM testData2 x LEFT SEMI JOIN testData2 y ON x.a >= y.a + 2"),
357-
Seq(Row(3,1), Row(3,2))
357+
Seq(Row(3, 1), Row(3, 2))
358358
)
359359
}
360360

@@ -371,16 +371,16 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
371371
test("agg") {
372372
checkAnswer(
373373
sql("SELECT a, SUM(b) FROM testData2 GROUP BY a"),
374-
Seq(Row(1,3), Row(2,3), Row(3,3)))
374+
Seq(Row(1, 3), Row(2, 3), Row(3, 3)))
375375
}
376376

377377
test("literal in agg grouping expressions") {
378378
checkAnswer(
379379
sql("SELECT a, count(1) FROM testData2 GROUP BY a, 1"),
380-
Seq(Row(1,2), Row(2,2), Row(3,2)))
380+
Seq(Row(1, 2), Row(2, 2), Row(3, 2)))
381381
checkAnswer(
382382
sql("SELECT a, count(2) FROM testData2 GROUP BY a, 2"),
383-
Seq(Row(1,2), Row(2,2), Row(3,2)))
383+
Seq(Row(1, 2), Row(2, 2), Row(3, 2)))
384384
}
385385

386386
test("aggregates with nulls") {
@@ -405,19 +405,19 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
405405
def sortTest(): Unit = {
406406
checkAnswer(
407407
sql("SELECT * FROM testData2 ORDER BY a ASC, b ASC"),
408-
Seq(Row(1,1), Row(1,2), Row(2,1), Row(2,2), Row(3,1), Row(3,2)))
408+
Seq(Row(1, 1), Row(1, 2), Row(2, 1), Row(2, 2), Row(3, 1), Row(3, 2)))
409409

410410
checkAnswer(
411411
sql("SELECT * FROM testData2 ORDER BY a ASC, b DESC"),
412-
Seq(Row(1,2), Row(1,1), Row(2,2), Row(2,1), Row(3,2), Row(3,1)))
412+
Seq(Row(1, 2), Row(1, 1), Row(2, 2), Row(2, 1), Row(3, 2), Row(3, 1)))
413413

414414
checkAnswer(
415415
sql("SELECT * FROM testData2 ORDER BY a DESC, b DESC"),
416-
Seq(Row(3,2), Row(3,1), Row(2,2), Row(2,1), Row(1,2), Row(1,1)))
416+
Seq(Row(3, 2), Row(3, 1), Row(2, 2), Row(2, 1), Row(1, 2), Row(1, 1)))
417417

418418
checkAnswer(
419419
sql("SELECT * FROM testData2 ORDER BY a DESC, b ASC"),
420-
Seq(Row(3,1), Row(3,2), Row(2,1), Row(2,2), Row(1,1), Row(1,2)))
420+
Seq(Row(3, 1), Row(3, 2), Row(2, 1), Row(2, 2), Row(1, 1), Row(1, 2)))
421421

422422
checkAnswer(
423423
sql("SELECT b FROM binaryData ORDER BY a ASC"),
@@ -552,7 +552,7 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
552552
test("average overflow") {
553553
checkAnswer(
554554
sql("SELECT AVG(a),b FROM largeAndSmallInts group by b"),
555-
Seq(Row(2147483645.0,1), Row(2.0,2)))
555+
Seq(Row(2147483645.0, 1), Row(2.0, 2)))
556556
}
557557

558558
test("count") {
@@ -619,10 +619,10 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
619619
| (SELECT * FROM testData2 WHERE a = 1) x JOIN
620620
| (SELECT * FROM testData2 WHERE a = 1) y
621621
|WHERE x.a = y.a""".stripMargin),
622-
Row(1,1,1,1) ::
623-
Row(1,1,1,2) ::
624-
Row(1,2,1,1) ::
625-
Row(1,2,1,2) :: Nil)
622+
Row(1, 1, 1, 1) ::
623+
Row(1, 1, 1, 2) ::
624+
Row(1, 2, 1, 1) ::
625+
Row(1, 2, 1, 2) :: Nil)
626626
}
627627

628628
test("inner join, no matches") {
@@ -1266,22 +1266,22 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
12661266
test("SPARK-4432 Fix attribute reference resolution error when using ORDER BY") {
12671267
checkAnswer(
12681268
sql("SELECT a + b FROM testData2 ORDER BY a"),
1269-
Seq(2, 3, 3 ,4 ,4 ,5).map(Row(_))
1269+
Seq(2, 3, 3, 4, 4, 5).map(Row(_))
12701270
)
12711271
}
12721272

12731273
test("oder by asc by default when not specify ascending and descending") {
12741274
checkAnswer(
12751275
sql("SELECT a, b FROM testData2 ORDER BY a desc, b"),
1276-
Seq(Row(3, 1), Row(3, 2), Row(2, 1), Row(2,2), Row(1, 1), Row(1, 2))
1276+
Seq(Row(3, 1), Row(3, 2), Row(2, 1), Row(2, 2), Row(1, 1), Row(1, 2))
12771277
)
12781278
}
12791279

12801280
test("Supporting relational operator '<=>' in Spark SQL") {
1281-
val nullCheckData1 = TestData(1,"1") :: TestData(2,null) :: Nil
1281+
val nullCheckData1 = TestData(1, "1") :: TestData(2, null) :: Nil
12821282
val rdd1 = sparkContext.parallelize((0 to 1).map(i => nullCheckData1(i)))
12831283
rdd1.toDF().registerTempTable("nulldata1")
1284-
val nullCheckData2 = TestData(1,"1") :: TestData(2,null) :: Nil
1284+
val nullCheckData2 = TestData(1, "1") :: TestData(2, null) :: Nil
12851285
val rdd2 = sparkContext.parallelize((0 to 1).map(i => nullCheckData2(i)))
12861286
rdd2.toDF().registerTempTable("nulldata2")
12871287
checkAnswer(sql("SELECT nulldata1.key FROM nulldata1 join " +
@@ -1290,7 +1290,7 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
12901290
}
12911291

12921292
test("Multi-column COUNT(DISTINCT ...)") {
1293-
val data = TestData(1,"val_1") :: TestData(2,"val_2") :: Nil
1293+
val data = TestData(1, "val_1") :: TestData(2, "val_2") :: Nil
12941294
val rdd = sparkContext.parallelize((0 to 1).map(i => data(i)))
12951295
rdd.toDF().registerTempTable("distinctData")
12961296
checkAnswer(sql("SELECT COUNT(DISTINCT key,value) FROM distinctData"), Row(2))

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ class ScalaReflectionRelationSuite extends FunSuite {
8080

8181
test("query case class RDD") {
8282
val data = ReflectData("a", 1, 1L, 1.toFloat, 1.toDouble, 1.toShort, 1.toByte, true,
83-
new java.math.BigDecimal(1), new Date(12345), new Timestamp(12345), Seq(1,2,3))
83+
new java.math.BigDecimal(1), new Date(12345), new Timestamp(12345), Seq(1, 2, 3))
8484
val rdd = sparkContext.parallelize(data :: Nil)
8585
rdd.toDF().registerTempTable("reflectData")
8686

8787
assert(sql("SELECT * FROM reflectData").collect().head ===
8888
Row("a", 1, 1L, 1.toFloat, 1.toDouble, 1.toShort, 1.toByte, true,
8989
new java.math.BigDecimal(1), Date.valueOf("1970-01-01"),
90-
new Timestamp(12345), Seq(1,2,3)))
90+
new Timestamp(12345), Seq(1, 2, 3)))
9191
}
9292

9393
test("query case class RDD with nulls") {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ object TestData {
109109
case class ArrayData(data: Seq[Int], nestedData: Seq[Seq[Int]])
110110
val arrayData =
111111
TestSQLContext.sparkContext.parallelize(
112-
ArrayData(Seq(1,2,3), Seq(Seq(1,2,3))) ::
113-
ArrayData(Seq(2,3,4), Seq(Seq(2,3,4))) :: Nil)
112+
ArrayData(Seq(1, 2, 3), Seq(Seq(1, 2, 3))) ::
113+
ArrayData(Seq(2, 3, 4), Seq(Seq(2, 3, 4))) :: Nil)
114114
arrayData.toDF().registerTempTable("arrayData")
115115

116116
case class MapData(data: scala.collection.Map[Int, String])

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class UDFSuite extends QueryTest {
3838
}
3939

4040
test("TwoArgument UDF") {
41-
udf.register("strLenScala", (_: String).length + (_:Int))
41+
udf.register("strLenScala", (_: String).length + (_: Int))
4242
assert(sql("SELECT strLenScala('test', 1)").head().getInt(0) === 5)
4343
}
4444

sql/core/src/test/scala/org/apache/spark/sql/columnar/ColumnTypeSuite.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class ColumnTypeSuite extends FunSuite with Logging {
7373
checkActualSize(TIMESTAMP, new Timestamp(0L), 12)
7474

7575
val binary = Array.fill[Byte](4)(0: Byte)
76-
checkActualSize(BINARY, binary, 4 + 4)
76+
checkActualSize(BINARY, binary, 4 + 4)
7777

7878
val generic = Map(1 -> "a")
7979
checkActualSize(GENERIC, SparkSqlSerializer.serialize(generic), 4 + 8)
@@ -167,7 +167,7 @@ class ColumnTypeSuite extends FunSuite with Logging {
167167
val serializer = new SparkSqlSerializer(conf).newInstance()
168168

169169
val buffer = ByteBuffer.allocate(512)
170-
val obj = CustomClass(Int.MaxValue,Long.MaxValue)
170+
val obj = CustomClass(Int.MaxValue, Long.MaxValue)
171171
val serializedObj = serializer.serialize(obj).array()
172172

173173
GENERIC.append(serializer.serialize(obj).array(), buffer)
@@ -278,7 +278,7 @@ private[columnar] object CustomerSerializer extends Serializer[CustomClass] {
278278
override def read(kryo: Kryo, input: Input, aClass: Class[CustomClass]): CustomClass = {
279279
val a = input.readInt()
280280
val b = input.readLong()
281-
CustomClass(a,b)
281+
CustomClass(a, b)
282282
}
283283
}
284284

0 commit comments

Comments
 (0)