File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed
main/scala/org/apache/spark/sql/internal
test/scala/org/apache/spark/sql Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,11 @@ object SQLConf {
5050 sqlConfEntries.put(entry.key, entry)
5151 }
5252
53+ // For testing only
54+ private [sql] def unregister (entry : ConfigEntry [_]): Unit = sqlConfEntries.synchronized {
55+ sqlConfEntries.remove(entry.key)
56+ }
57+
5358 private [sql] object SQLConfigBuilder {
5459
5560 def apply (key : String ): ConfigBuilder = new ConfigBuilder (key).onCreate(register)
Original file line number Diff line number Diff line change @@ -982,7 +982,7 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext {
982982 spark.sessionState.conf.clear()
983983 }
984984
985- test(" SPARK-19218 Fix SET command to show a result correctly and in a sorted order" ) {
985+ test(" SPARK-19218 SET command should show a result in a sorted order" ) {
986986 val overrideConfs = sql(" SET" ).collect()
987987 sql(s " SET test.key3=1 " )
988988 sql(s " SET test.key2=2 " )
@@ -994,14 +994,19 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext {
994994 Row (" test.key2" , " 2" ),
995995 Row (" test.key3" , " 1" ))).sortBy(_.getString(0 ))
996996 )
997+ }
997998
998- // Previsouly, `SET -v` fails with NPE during decoding for null value.
999+ test( " SPARK-19218 `SET -v` should not fail with null value configuration " ) {
9991000 import SQLConf ._
1000- SQLConfigBuilder (" spark.test" ).doc(" doc" ).stringConf.createWithDefault(null )
1001+ val confEntry = SQLConfigBuilder (" spark.test" ).doc(" doc" ).stringConf.createWithDefault(null )
10011002
1002- val result2 = sql(" SET -v" ).collect()
1003- assert(result2 === result2.sortBy(_.getString(0 )))
1004- spark.sessionState.conf.clear()
1003+ try {
1004+ val result = sql(" SET -v" ).collect()
1005+ assert(result === result.sortBy(_.getString(0 )))
1006+ spark.sessionState.conf.clear()
1007+ } finally {
1008+ SQLConf .unregister(confEntry)
1009+ }
10051010 }
10061011
10071012 test(" SET commands with illegal or inappropriate argument" ) {
You can’t perform that action at this time.
0 commit comments