Skip to content

Commit 6ae9fc0

Browse files
rxinAndrew Or
authored andcommitted
[SPARK-15126][SQL] RuntimeConfig.set should return Unit
## What changes were proposed in this pull request? Currently we return RuntimeConfig itself to facilitate chaining. However, it makes the output in interactive environments (e.g. notebooks, scala repl) weird because it'd show the response of calling set as a RuntimeConfig itself. ## How was this patch tested? Updated unit tests. Author: Reynold Xin <[email protected]> Closes #12902 from rxin/SPARK-15126.
1 parent 0fd3a47 commit 6ae9fc0

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

python/pyspark/sql/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class RuntimeConfig(object):
2323
"""User-facing configuration API, accessible through `SparkSession.conf`.
2424
2525
Options set here are automatically propagated to the Hadoop configuration during I/O.
26-
This a thin wrapper around its Scala implementation org.apache.spark.sql.RuntimeConfig.
2726
"""
2827

2928
def __init__(self, jconf):

python/pyspark/sql/session.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ class SparkSession(object):
7171
.config("spark.some.config.option", "some-value") \
7272
.getOrCreate()
7373
74-
:param sparkContext: The :class:`SparkContext` backing this SparkSession.
75-
:param jsparkSession: An optional JVM Scala SparkSession. If set, we do not instantiate a new
76-
SparkSession in the JVM, instead we make all calls to this object.
7774
"""
7875

7976
class Builder(object):

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,16 @@ class RuntimeConfig private[sql](sqlConf: SQLConf = new SQLConf) {
3535
*
3636
* @since 2.0.0
3737
*/
38-
def set(key: String, value: String): RuntimeConfig = {
38+
def set(key: String, value: String): Unit = {
3939
sqlConf.setConfString(key, value)
40-
this
4140
}
4241

4342
/**
4443
* Sets the given Spark runtime configuration property.
4544
*
4645
* @since 2.0.0
4746
*/
48-
def set(key: String, value: Boolean): RuntimeConfig = {
47+
def set(key: String, value: Boolean): Unit = {
4948
set(key, value.toString)
5049
}
5150

@@ -54,7 +53,7 @@ class RuntimeConfig private[sql](sqlConf: SQLConf = new SQLConf) {
5453
*
5554
* @since 2.0.0
5655
*/
57-
def set(key: String, value: Long): RuntimeConfig = {
56+
def set(key: String, value: Long): Unit = {
5857
set(key, value.toString)
5958
}
6059

sql/core/src/test/scala/org/apache/spark/sql/internal/RuntimeConfigSuite.scala renamed to sql/core/src/test/scala/org/apache/spark/sql/RuntimeConfigSuite.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,19 @@
1515
* limitations under the License.
1616
*/
1717

18-
package org.apache.spark.sql.internal
18+
package org.apache.spark.sql
1919

2020
import org.apache.spark.SparkFunSuite
21-
import org.apache.spark.sql.RuntimeConfig
2221

2322
class RuntimeConfigSuite extends SparkFunSuite {
2423

2524
private def newConf(): RuntimeConfig = new RuntimeConfig
2625

2726
test("set and get") {
2827
val conf = newConf()
29-
conf
30-
.set("k1", "v1")
31-
.set("k2", 2)
32-
.set("k3", value = false)
28+
conf.set("k1", "v1")
29+
conf.set("k2", 2)
30+
conf.set("k3", value = false)
3331

3432
assert(conf.get("k1") == "v1")
3533
assert(conf.get("k2") == "2")
@@ -41,13 +39,15 @@ class RuntimeConfigSuite extends SparkFunSuite {
4139
}
4240

4341
test("getOption") {
44-
val conf = newConf().set("k1", "v1")
42+
val conf = newConf()
43+
conf.set("k1", "v1")
4544
assert(conf.getOption("k1") == Some("v1"))
4645
assert(conf.getOption("notset") == None)
4746
}
4847

4948
test("unset") {
50-
val conf = newConf().set("k1", "v1")
49+
val conf = newConf()
50+
conf.set("k1", "v1")
5151
assert(conf.get("k1") == "v1")
5252
conf.unset("k1")
5353
intercept[NoSuchElementException] {

0 commit comments

Comments
 (0)