Repository: spark Updated Branches: refs/heads/branch-2.0 e868a15a7 -> 45862f6c9
[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 <r...@databricks.com> Closes #12902 from rxin/SPARK-15126. (cherry picked from commit 6ae9fc00ed6ef530a9c42c8407fc66fd873239cc) Signed-off-by: Andrew Or <and...@databricks.com> Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/45862f6c Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/45862f6c Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/45862f6c Branch: refs/heads/branch-2.0 Commit: 45862f6c935c36969a62a3fbb863cce55c4a6426 Parents: e868a15 Author: Reynold Xin <r...@databricks.com> Authored: Wed May 4 14:26:05 2016 -0700 Committer: Andrew Or <and...@databricks.com> Committed: Wed May 4 14:26:16 2016 -0700 ---------------------------------------------------------------------- python/pyspark/sql/conf.py | 1 - python/pyspark/sql/session.py | 3 -- .../org/apache/spark/sql/RuntimeConfig.scala | 7 ++- .../apache/spark/sql/RuntimeConfigSuite.scala | 57 ++++++++++++++++++++ .../spark/sql/internal/RuntimeConfigSuite.scala | 57 -------------------- 5 files changed, 60 insertions(+), 65 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/45862f6c/python/pyspark/sql/conf.py ---------------------------------------------------------------------- diff --git a/python/pyspark/sql/conf.py b/python/pyspark/sql/conf.py index 7428c91..609d882 100644 --- a/python/pyspark/sql/conf.py +++ b/python/pyspark/sql/conf.py @@ -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): http://git-wip-us.apache.org/repos/asf/spark/blob/45862f6c/python/pyspark/sql/session.py ---------------------------------------------------------------------- diff --git a/python/pyspark/sql/session.py b/python/pyspark/sql/session.py index fb3e318..04842f6 100644 --- a/python/pyspark/sql/session.py +++ b/python/pyspark/sql/session.py @@ -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): http://git-wip-us.apache.org/repos/asf/spark/blob/45862f6c/sql/core/src/main/scala/org/apache/spark/sql/RuntimeConfig.scala ---------------------------------------------------------------------- diff --git a/sql/core/src/main/scala/org/apache/spark/sql/RuntimeConfig.scala b/sql/core/src/main/scala/org/apache/spark/sql/RuntimeConfig.scala index 4fd6e42..7e07e0c 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/RuntimeConfig.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/RuntimeConfig.scala @@ -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) } http://git-wip-us.apache.org/repos/asf/spark/blob/45862f6c/sql/core/src/test/scala/org/apache/spark/sql/RuntimeConfigSuite.scala ---------------------------------------------------------------------- diff --git a/sql/core/src/test/scala/org/apache/spark/sql/RuntimeConfigSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/RuntimeConfigSuite.scala new file mode 100644 index 0000000..cfe2e9f --- /dev/null +++ b/sql/core/src/test/scala/org/apache/spark/sql/RuntimeConfigSuite.scala @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.sql + +import org.apache.spark.SparkFunSuite + +class RuntimeConfigSuite extends SparkFunSuite { + + private def newConf(): RuntimeConfig = new RuntimeConfig + + test("set and get") { + val conf = newConf() + conf.set("k1", "v1") + conf.set("k2", 2) + conf.set("k3", value = false) + + assert(conf.get("k1") == "v1") + assert(conf.get("k2") == "2") + assert(conf.get("k3") == "false") + + intercept[NoSuchElementException] { + conf.get("notset") + } + } + + test("getOption") { + val conf = newConf() + conf.set("k1", "v1") + assert(conf.getOption("k1") == Some("v1")) + assert(conf.getOption("notset") == None) + } + + test("unset") { + val conf = newConf() + conf.set("k1", "v1") + assert(conf.get("k1") == "v1") + conf.unset("k1") + intercept[NoSuchElementException] { + conf.get("k1") + } + } +} http://git-wip-us.apache.org/repos/asf/spark/blob/45862f6c/sql/core/src/test/scala/org/apache/spark/sql/internal/RuntimeConfigSuite.scala ---------------------------------------------------------------------- diff --git a/sql/core/src/test/scala/org/apache/spark/sql/internal/RuntimeConfigSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/internal/RuntimeConfigSuite.scala deleted file mode 100644 index a629b73..0000000 --- a/sql/core/src/test/scala/org/apache/spark/sql/internal/RuntimeConfigSuite.scala +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.spark.sql.internal - -import org.apache.spark.SparkFunSuite -import org.apache.spark.sql.RuntimeConfig - -class RuntimeConfigSuite extends SparkFunSuite { - - private def newConf(): RuntimeConfig = new RuntimeConfig - - test("set and get") { - val conf = newConf() - conf - .set("k1", "v1") - .set("k2", 2) - .set("k3", value = false) - - assert(conf.get("k1") == "v1") - assert(conf.get("k2") == "2") - assert(conf.get("k3") == "false") - - intercept[NoSuchElementException] { - conf.get("notset") - } - } - - test("getOption") { - val conf = newConf().set("k1", "v1") - assert(conf.getOption("k1") == Some("v1")) - assert(conf.getOption("notset") == None) - } - - test("unset") { - val conf = newConf().set("k1", "v1") - assert(conf.get("k1") == "v1") - conf.unset("k1") - intercept[NoSuchElementException] { - conf.get("k1") - } - } -} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org