-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-19218][SQL] Fix SET command to show a result correctly and in a sorted order #16579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
c182c7d
2ed6d87
fa4914b
fb578d1
0214fad
528b0fd
387ab59
7061cd9
7879201
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,16 +79,17 @@ case class SetCommand(kv: Option[(String, Option[String])]) extends RunnableComm | |
| // Queries all key-value pairs that are set in the SQLConf of the sparkSession. | ||
| case None => | ||
| val runFunc = (sparkSession: SparkSession) => { | ||
| sparkSession.conf.getAll.map { case (k, v) => Row(k, v) }.toSeq | ||
| sparkSession.conf.getAll.toSeq.sorted.map { case (k, v) => Row(k, v) } | ||
| } | ||
| (keyValueOutput, runFunc) | ||
|
|
||
| // Queries all properties along with their default values and docs that are defined in the | ||
| // SQLConf of the sparkSession. | ||
| case Some(("-v", None)) => | ||
| val runFunc = (sparkSession: SparkSession) => { | ||
| sparkSession.sessionState.conf.getAllDefinedConfs.map { case (key, defaultValue, doc) => | ||
| Row(key, defaultValue, doc) | ||
| sparkSession.sessionState.conf.getAllDefinedConfs.sorted.map { | ||
| case (key, defaultValue, doc) => | ||
| Row(key, if (defaultValue == null) "null" else defaultValue, doc) | ||
|
||
| } | ||
| } | ||
| val schema = StructType( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -982,6 +982,24 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext { | |
| spark.sessionState.conf.clear() | ||
| } | ||
|
|
||
| test("SET commands should return a list sorted by key") { | ||
| val overrideConfs = sql("SET").collect() | ||
| sql(s"SET test.key3=1") | ||
| sql(s"SET test.key2=2") | ||
| sql(s"SET test.key1=3") | ||
| val result = sql("SET").collect() | ||
| assert(result === | ||
| (overrideConfs ++ Seq( | ||
| Row("test.key1", "3"), | ||
| Row("test.key2", "2"), | ||
| Row("test.key3", "1"))).sortBy(_.getString(0)) | ||
| ) | ||
|
|
||
| val result2 = sql("SET -v").collect() | ||
| assert(result2 === result2.sortBy(_.getString(0))) | ||
| spark.sessionState.conf.clear() | ||
|
||
| } | ||
|
|
||
| test("SET commands with illegal or inappropriate argument") { | ||
| spark.sessionState.conf.clear() | ||
| // Set negative mapred.reduce.tasks for automatically determining | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the root cause to raise exceptions during decoding.