Skip to content

Commit d005b03

Browse files
committed
Made "SET key=value" returns the newly set key value pair
1 parent f6c7715 commit d005b03

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/commands.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ case class SetCommand(
4848
// Set value for key k.
4949
case (Some(k), Some(v)) =>
5050
context.set(k, v)
51-
Array.empty[(String, String)]
51+
Array(k -> v)
5252

5353
// Query the value bound to key k.
5454
case (Some(k), _) =>

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,12 @@ class HiveQuerySuite extends HiveComparisonTest {
250250
clear()
251251

252252
// "set" itself returns all config variables currently specified in SQLConf.
253-
assert(hql("set").collect().size == 0)
253+
assert(hql("SET").collect().size == 0)
254+
255+
assertResult(Array(testKey -> testVal)) {
256+
rowsToPairs(hql(s"SET $testKey=$testVal").collect())
257+
}
254258

255-
// "set key=val"
256-
hql(s"SET $testKey=$testVal")
257259
assert(hiveconf.get(testKey, "") == testVal)
258260
assertResult(Array(testKey -> testVal)) {
259261
rowsToPairs(hql("SET").collect())
@@ -278,7 +280,10 @@ class HiveQuerySuite extends HiveComparisonTest {
278280
clear()
279281
assert(sql("SET").collect().size == 0)
280282

281-
sql(s"SET $testKey=$testVal")
283+
assertResult(Array(testKey -> testVal)) {
284+
rowsToPairs(sql(s"SET $testKey=$testVal").collect())
285+
}
286+
282287
assert(hiveconf.get(testKey, "") == testVal)
283288
assertResult(Array(testKey -> testVal)) {
284289
rowsToPairs(sql("SET").collect())

0 commit comments

Comments
 (0)