Skip to content
Snippets Groups Projects
Commit 6ae9fc00 authored by Reynold Xin's avatar Reynold Xin Committed by Andrew Or
Browse files

[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 <rxin@databricks.com>

Closes #12902 from rxin/SPARK-15126.
parent 0fd3a474
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,6 @@ class RuntimeConfig(object):
"""User-facing configuration API, accessible through `SparkSession.conf`.
Options set here are automatically propagated to the Hadoop configuration during I/O.
This a thin wrapper around its Scala implementation org.apache.spark.sql.RuntimeConfig.
"""
def __init__(self, jconf):
......
......@@ -71,9 +71,6 @@ class SparkSession(object):
.config("spark.some.config.option", "some-value") \
.getOrCreate()
:param sparkContext: The :class:`SparkContext` backing this SparkSession.
:param jsparkSession: An optional JVM Scala SparkSession. If set, we do not instantiate a new
SparkSession in the JVM, instead we make all calls to this object.
"""
class Builder(object):
......
......@@ -35,9 +35,8 @@ class RuntimeConfig private[sql](sqlConf: SQLConf = new SQLConf) {
*
* @since 2.0.0
*/
def set(key: String, value: String): RuntimeConfig = {
def set(key: String, value: String): Unit = {
sqlConf.setConfString(key, value)
this
}
/**
......@@ -45,7 +44,7 @@ class RuntimeConfig private[sql](sqlConf: SQLConf = new SQLConf) {
*
* @since 2.0.0
*/
def set(key: String, value: Boolean): RuntimeConfig = {
def set(key: String, value: Boolean): Unit = {
set(key, value.toString)
}
......@@ -54,7 +53,7 @@ class RuntimeConfig private[sql](sqlConf: SQLConf = new SQLConf) {
*
* @since 2.0.0
*/
def set(key: String, value: Long): RuntimeConfig = {
def set(key: String, value: Long): Unit = {
set(key, value.toString)
}
......
......@@ -15,10 +15,9 @@
* limitations under the License.
*/
package org.apache.spark.sql.internal
package org.apache.spark.sql
import org.apache.spark.SparkFunSuite
import org.apache.spark.sql.RuntimeConfig
class RuntimeConfigSuite extends SparkFunSuite {
......@@ -26,10 +25,9 @@ class RuntimeConfigSuite extends SparkFunSuite {
test("set and get") {
val conf = newConf()
conf
.set("k1", "v1")
.set("k2", 2)
.set("k3", value = false)
conf.set("k1", "v1")
conf.set("k2", 2)
conf.set("k3", value = false)
assert(conf.get("k1") == "v1")
assert(conf.get("k2") == "2")
......@@ -41,13 +39,15 @@ class RuntimeConfigSuite extends SparkFunSuite {
}
test("getOption") {
val conf = newConf().set("k1", "v1")
val conf = newConf()
conf.set("k1", "v1")
assert(conf.getOption("k1") == Some("v1"))
assert(conf.getOption("notset") == None)
}
test("unset") {
val conf = newConf().set("k1", "v1")
val conf = newConf()
conf.set("k1", "v1")
assert(conf.get("k1") == "v1")
conf.unset("k1")
intercept[NoSuchElementException] {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment