Skip to content

Commit 1083e9d

Browse files
committed
Fixed failed test suites
1 parent 7db82a1 commit 1083e9d

File tree

3 files changed

+38
-35
lines changed

3 files changed

+38
-35
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ class SQLConfSuite extends QueryTest {
5454
assert(get(testKey, testVal + "_") == testVal)
5555
assert(TestSQLContext.get(testKey, testVal + "_") == testVal)
5656

57-
sql("set mapred.reduce.tasks=20")
58-
assert(get("mapred.reduce.tasks", "0") == "20")
59-
sql("set mapred.reduce.tasks = 40")
60-
assert(get("mapred.reduce.tasks", "0") == "40")
57+
sql("set some.property=20")
58+
assert(get("some.property", "0") == "20")
59+
sql("set some.property = 40")
60+
assert(get("some.property", "0") == "40")
6161

6262
val key = "spark.sql.key"
6363
val vs = "val0,val_1,val2.3,my_table"
@@ -70,4 +70,9 @@ class SQLConfSuite extends QueryTest {
7070
clear()
7171
}
7272

73+
test("deprecated property") {
74+
clear()
75+
sql(s"set ${SQLConf.Deprecated.MAPRED_REDUCE_TASKS}=10")
76+
assert(get(SQLConf.SHUFFLE_PARTITIONS) == "10")
77+
}
7378
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,25 +424,25 @@ class SQLQuerySuite extends QueryTest {
424424
sql(s"SET $testKey=$testVal")
425425
checkAnswer(
426426
sql("SET"),
427-
Seq(Seq(testKey, testVal))
427+
Seq(Seq(s"$testKey=$testVal"))
428428
)
429429

430430
sql(s"SET ${testKey + testKey}=${testVal + testVal}")
431431
checkAnswer(
432432
sql("set"),
433433
Seq(
434-
Seq(testKey, testVal),
435-
Seq(testKey + testKey, testVal + testVal))
434+
Seq(s"$testKey=$testVal"),
435+
Seq(s"${testKey + testKey}=${testVal + testVal}"))
436436
)
437437

438438
// "set key"
439439
checkAnswer(
440440
sql(s"SET $testKey"),
441-
Seq(Seq(testKey, testVal))
441+
Seq(Seq(s"$testKey=$testVal"))
442442
)
443443
checkAnswer(
444444
sql(s"SET $nonexistentKey"),
445-
Seq(Seq(nonexistentKey, "<undefined>"))
445+
Seq(Seq(s"$nonexistentKey=<undefined>"))
446446
)
447447
clear()
448448
}

sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,10 @@ class HiveQuerySuite extends HiveComparisonTest {
416416
hql(s"set $testKey=$testVal")
417417
assert(get(testKey, testVal + "_") == testVal)
418418

419-
hql("set mapred.reduce.tasks=20")
420-
assert(get("mapred.reduce.tasks", "0") == "20")
421-
hql("set mapred.reduce.tasks = 40")
422-
assert(get("mapred.reduce.tasks", "0") == "40")
419+
hql("set some.property=20")
420+
assert(get("some.property", "0") == "20")
421+
hql("set some.property = 40")
422+
assert(get("some.property", "0") == "40")
423423

424424
hql(s"set $testKey=$testVal")
425425
assert(get(testKey, "0") == testVal)
@@ -433,63 +433,61 @@ class HiveQuerySuite extends HiveComparisonTest {
433433
val testKey = "spark.sql.key.usedfortestonly"
434434
val testVal = "test.val.0"
435435
val nonexistentKey = "nonexistent"
436-
def collectResults(rdd: SchemaRDD): Set[(String, String)] =
437-
rdd.collect().map { case Row(key: String, value: String) => key -> value }.toSet
438436

439437
clear()
440438

441439
// "set" itself returns all config variables currently specified in SQLConf.
442440
assert(hql("SET").collect().size == 0)
443441

444-
assertResult(Set(testKey -> testVal)) {
445-
collectResults(hql(s"SET $testKey=$testVal"))
442+
assertResult(Array(s"$testKey=$testVal")) {
443+
hql(s"SET $testKey=$testVal").collect().map(_.getString(0))
446444
}
447445

448446
assert(hiveconf.get(testKey, "") == testVal)
449-
assertResult(Set(testKey -> testVal)) {
450-
collectResults(hql("SET"))
447+
assertResult(Array(s"$testKey=$testVal")) {
448+
hql(s"SET $testKey=$testVal").collect().map(_.getString(0))
451449
}
452450

453451
hql(s"SET ${testKey + testKey}=${testVal + testVal}")
454452
assert(hiveconf.get(testKey + testKey, "") == testVal + testVal)
455-
assertResult(Set(testKey -> testVal, (testKey + testKey) -> (testVal + testVal))) {
456-
collectResults(hql("SET"))
453+
assertResult(Array(s"$testKey=$testVal", s"${testKey + testKey}=${testVal + testVal}")) {
454+
hql(s"SET").collect().map(_.getString(0))
457455
}
458456

459457
// "set key"
460-
assertResult(Set(testKey -> testVal)) {
461-
collectResults(hql(s"SET $testKey"))
458+
assertResult(Array(s"$testKey=$testVal")) {
459+
hql(s"SET $testKey").collect().map(_.getString(0))
462460
}
463461

464-
assertResult(Set(nonexistentKey -> "<undefined>")) {
465-
collectResults(hql(s"SET $nonexistentKey"))
462+
assertResult(Array(s"$nonexistentKey=<undefined>")) {
463+
hql(s"SET $nonexistentKey").collect().map(_.getString(0))
466464
}
467465

468466
// Assert that sql() should have the same effects as hql() by repeating the above using sql().
469467
clear()
470468
assert(sql("SET").collect().size == 0)
471469

472-
assertResult(Set(testKey -> testVal)) {
473-
collectResults(sql(s"SET $testKey=$testVal"))
470+
assertResult(Array(s"$testKey=$testVal")) {
471+
sql(s"SET $testKey=$testVal").collect().map(_.getString(0))
474472
}
475473

476474
assert(hiveconf.get(testKey, "") == testVal)
477-
assertResult(Set(testKey -> testVal)) {
478-
collectResults(sql("SET"))
475+
assertResult(Array(s"$testKey=$testVal")) {
476+
sql("SET").collect().map(_.getString(0))
479477
}
480478

481479
sql(s"SET ${testKey + testKey}=${testVal + testVal}")
482480
assert(hiveconf.get(testKey + testKey, "") == testVal + testVal)
483-
assertResult(Set(testKey -> testVal, (testKey + testKey) -> (testVal + testVal))) {
484-
collectResults(sql("SET"))
481+
assertResult(Array(s"$testKey=$testVal", s"${testKey + testKey}=${testVal + testVal}")) {
482+
sql("SET").collect().map(_.getString(0))
485483
}
486484

487-
assertResult(Set(testKey -> testVal)) {
488-
collectResults(sql(s"SET $testKey"))
485+
assertResult(Array(s"$testKey=$testVal")) {
486+
sql(s"SET $testKey").collect().map(_.getString(0))
489487
}
490488

491-
assertResult(Set(nonexistentKey -> "<undefined>")) {
492-
collectResults(sql(s"SET $nonexistentKey"))
489+
assertResult(Array(s"$nonexistentKey=<undefined>")) {
490+
sql(s"SET $nonexistentKey").collect().map(_.getString(0))
493491
}
494492

495493
clear()

0 commit comments

Comments
 (0)