Skip to content

Commit 3ac11ef

Browse files
committed
getAllConfs return an immutable Map instead of an Array.
1 parent 4b19d6c commit 3ac11ef

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

sql/core/src/main/scala/org/apache/spark/sql/SQLConf.scala

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717

1818
package org.apache.spark.sql
1919

20+
import scala.collection.immutable
21+
import scala.collection.JavaConversions._
22+
2023
import java.util.Properties
2124

22-
import scala.collection.JavaConverters._
2325

2426
private[spark] object SQLConf {
2527
val COMPRESS_CACHED = "spark.sql.inMemoryColumnarStorage.compressed"
@@ -105,10 +107,8 @@ trait SQLConf {
105107
/** ********************** SQLConf functionality methods ************ */
106108

107109
/** Set Spark SQL configuration properties. */
108-
def setConf(props: Properties): Unit = {
109-
settings.synchronized {
110-
props.asScala.foreach { case (k, v) => settings.put(k, v) }
111-
}
110+
def setConf(props: Properties): Unit = settings.synchronized {
111+
props.foreach { case (k, v) => settings.put(k, v) }
112112
}
113113

114114
/** Set the given Spark SQL configuration property. */
@@ -131,8 +131,11 @@ trait SQLConf {
131131
Option(settings.get(key)).getOrElse(defaultValue)
132132
}
133133

134-
/** Return all the configuration properties that have been set (i.e. not the default). */
135-
def getAllConfs: Array[(String, String)] = settings.synchronized { settings.asScala.toArray }
134+
/**
135+
* Return all the configuration properties that have been set (i.e. not the default).
136+
* This creates a new copy of the config properties in the form of a Map.
137+
*/
138+
def getAllConfs: immutable.Map[String, String] = settings.synchronized { settings.toMap }
136139

137140
private[spark] def clear() {
138141
settings.clear()

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
@@ -84,7 +84,7 @@ case class SetCommand(
8484
case (None, None) =>
8585
context.getAllConfs.map { case (k, v) =>
8686
s"$k=$v"
87-
}
87+
}.toSeq
8888

8989
case _ =>
9090
throw new IllegalArgumentException()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class SQLConfSuite extends QueryTest {
2929

3030
test("programmatic ways of basic setting and getting") {
3131
clear()
32-
assert(getAllConfs.toSet === Set())
32+
assert(getAllConfs.size === 0)
3333

3434
setConf(testKey, testVal)
3535
assert(getConf(testKey) == testVal)

0 commit comments

Comments
 (0)