Skip to content

Commit

Permalink
Fixed failed test suites
Browse files Browse the repository at this point in the history
  • Loading branch information
liancheng committed Jul 24, 2014
1 parent 7db82a1 commit 1083e9d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 35 deletions.
13 changes: 9 additions & 4 deletions sql/core/src/test/scala/org/apache/spark/sql/SQLConfSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class SQLConfSuite extends QueryTest {
assert(get(testKey, testVal + "_") == testVal)
assert(TestSQLContext.get(testKey, testVal + "_") == testVal)

sql("set mapred.reduce.tasks=20")
assert(get("mapred.reduce.tasks", "0") == "20")
sql("set mapred.reduce.tasks = 40")
assert(get("mapred.reduce.tasks", "0") == "40")
sql("set some.property=20")
assert(get("some.property", "0") == "20")
sql("set some.property = 40")
assert(get("some.property", "0") == "40")

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

test("deprecated property") {
clear()
sql(s"set ${SQLConf.Deprecated.MAPRED_REDUCE_TASKS}=10")
assert(get(SQLConf.SHUFFLE_PARTITIONS) == "10")
}
}
10 changes: 5 additions & 5 deletions sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -424,25 +424,25 @@ class SQLQuerySuite extends QueryTest {
sql(s"SET $testKey=$testVal")
checkAnswer(
sql("SET"),
Seq(Seq(testKey, testVal))
Seq(Seq(s"$testKey=$testVal"))
)

sql(s"SET ${testKey + testKey}=${testVal + testVal}")
checkAnswer(
sql("set"),
Seq(
Seq(testKey, testVal),
Seq(testKey + testKey, testVal + testVal))
Seq(s"$testKey=$testVal"),
Seq(s"${testKey + testKey}=${testVal + testVal}"))
)

// "set key"
checkAnswer(
sql(s"SET $testKey"),
Seq(Seq(testKey, testVal))
Seq(Seq(s"$testKey=$testVal"))
)
checkAnswer(
sql(s"SET $nonexistentKey"),
Seq(Seq(nonexistentKey, "<undefined>"))
Seq(Seq(s"$nonexistentKey=<undefined>"))
)
clear()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,10 @@ class HiveQuerySuite extends HiveComparisonTest {
hql(s"set $testKey=$testVal")
assert(get(testKey, testVal + "_") == testVal)

hql("set mapred.reduce.tasks=20")
assert(get("mapred.reduce.tasks", "0") == "20")
hql("set mapred.reduce.tasks = 40")
assert(get("mapred.reduce.tasks", "0") == "40")
hql("set some.property=20")
assert(get("some.property", "0") == "20")
hql("set some.property = 40")
assert(get("some.property", "0") == "40")

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

clear()

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

assertResult(Set(testKey -> testVal)) {
collectResults(hql(s"SET $testKey=$testVal"))
assertResult(Array(s"$testKey=$testVal")) {
hql(s"SET $testKey=$testVal").collect().map(_.getString(0))
}

assert(hiveconf.get(testKey, "") == testVal)
assertResult(Set(testKey -> testVal)) {
collectResults(hql("SET"))
assertResult(Array(s"$testKey=$testVal")) {
hql(s"SET $testKey=$testVal").collect().map(_.getString(0))
}

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

// "set key"
assertResult(Set(testKey -> testVal)) {
collectResults(hql(s"SET $testKey"))
assertResult(Array(s"$testKey=$testVal")) {
hql(s"SET $testKey").collect().map(_.getString(0))
}

assertResult(Set(nonexistentKey -> "<undefined>")) {
collectResults(hql(s"SET $nonexistentKey"))
assertResult(Array(s"$nonexistentKey=<undefined>")) {
hql(s"SET $nonexistentKey").collect().map(_.getString(0))
}

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

assertResult(Set(testKey -> testVal)) {
collectResults(sql(s"SET $testKey=$testVal"))
assertResult(Array(s"$testKey=$testVal")) {
sql(s"SET $testKey=$testVal").collect().map(_.getString(0))
}

assert(hiveconf.get(testKey, "") == testVal)
assertResult(Set(testKey -> testVal)) {
collectResults(sql("SET"))
assertResult(Array(s"$testKey=$testVal")) {
sql("SET").collect().map(_.getString(0))
}

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

assertResult(Set(testKey -> testVal)) {
collectResults(sql(s"SET $testKey"))
assertResult(Array(s"$testKey=$testVal")) {
sql(s"SET $testKey").collect().map(_.getString(0))
}

assertResult(Set(nonexistentKey -> "<undefined>")) {
collectResults(sql(s"SET $nonexistentKey"))
assertResult(Array(s"$nonexistentKey=<undefined>")) {
sql(s"SET $nonexistentKey").collect().map(_.getString(0))
}

clear()
Expand Down

0 comments on commit 1083e9d

Please sign in to comment.