Skip to content
Snippets Groups Projects
Commit a08153f8 authored by Michael Armbrust's avatar Michael Armbrust
Browse files

[SPARK-3646][SQL] Copy SQL configuration from SparkConf when a SQLContext is created.

This will allow us to take advantage of things like the spark.defaults file.

Author: Michael Armbrust <michael@databricks.com>

Closes #2493 from marmbrus/copySparkConf and squashes the following commits:

0bd1377 [Michael Armbrust] Copy SQL configuration from SparkConf when a SQLContext is created.
parent 1c62f97e
No related branches found
No related tags found
No related merge requests found
......@@ -75,6 +75,11 @@ class SQLContext(@transient val sparkContext: SparkContext)
protected[sql] def executePlan(plan: LogicalPlan): this.QueryExecution =
new this.QueryExecution { val logical = plan }
sparkContext.getConf.getAll.foreach {
case (key, value) if key.startsWith("spark.sql") => setConf(key, value)
case _ =>
}
/**
* :: DeveloperApi ::
* Allows catalyst LogicalPlans to be executed as a SchemaRDD. Note that the LogicalPlan
......
......@@ -22,7 +22,11 @@ import org.apache.spark.sql.{SQLConf, SQLContext}
/** A SQLContext that can be used for local testing. */
object TestSQLContext
extends SQLContext(new SparkContext("local[2]", "TestSQLContext", new SparkConf())) {
extends SQLContext(
new SparkContext(
"local[2]",
"TestSQLContext",
new SparkConf().set("spark.sql.testkey", "true"))) {
/** Fewer partitions to speed up testing. */
override private[spark] def numShufflePartitions: Int =
......
......@@ -17,16 +17,25 @@
package org.apache.spark.sql
import org.scalatest.FunSuiteLike
import org.apache.spark.sql.test._
/* Implicits */
import TestSQLContext._
class SQLConfSuite extends QueryTest {
class SQLConfSuite extends QueryTest with FunSuiteLike {
val testKey = "test.key.0"
val testVal = "test.val.0"
test("propagate from spark conf") {
// We create a new context here to avoid order dependence with other tests that might call
// clear().
val newContext = new SQLContext(TestSQLContext.sparkContext)
assert(newContext.getConf("spark.sql.testkey", "false") == "true")
}
test("programmatic ways of basic setting and getting") {
clear()
assert(getAllConfs.size === 0)
......
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