aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerman van Hovell <hvanhovell@databricks.com>2017-04-20 22:37:04 +0200
committerHerman van Hovell <hvanhovell@databricks.com>2017-04-20 22:37:04 +0200
commit033206355339677812a250b2b64818a261871fd2 (patch)
treed000d6c55f08f9454e87e13cea74c187593fdd20
parentd95e4d9d6a9705c534549add6d4a73d554e47274 (diff)
downloadspark-033206355339677812a250b2b64818a261871fd2.tar.gz
spark-033206355339677812a250b2b64818a261871fd2.tar.bz2
spark-033206355339677812a250b2b64818a261871fd2.zip
[SPARK-20410][SQL] Make sparkConf a def in SharedSQLContext
## What changes were proposed in this pull request? It is kind of annoying that `SharedSQLContext.sparkConf` is a val when overriding test cases, because you cannot call `super` on it. This PR makes it a function. ## How was this patch tested? Existing tests. Author: Herman van Hovell <hvanhovell@databricks.com> Closes #17705 from hvanhovell/SPARK-20410.
-rw-r--r--sql/core/src/test/scala/org/apache/spark/sql/AggregateHashMapSuite.scala35
-rw-r--r--sql/core/src/test/scala/org/apache/spark/sql/DatasetSerializerRegistratorSuite.scala12
-rw-r--r--sql/core/src/test/scala/org/apache/spark/sql/execution/DataSourceScanExecRedactionSuite.scala11
-rw-r--r--sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/FileSourceStrategySuite.scala2
-rw-r--r--sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/CompactibleFileStreamLogSuite.scala4
-rw-r--r--sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/HDFSMetadataLogSuite.scala4
-rw-r--r--sql/core/src/test/scala/org/apache/spark/sql/test/SharedSQLContext.scala7
7 files changed, 32 insertions, 43 deletions
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/AggregateHashMapSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/AggregateHashMapSuite.scala
index 3e85d95523..7e61a68025 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/AggregateHashMapSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/AggregateHashMapSuite.scala
@@ -19,13 +19,12 @@ package org.apache.spark.sql
import org.scalatest.BeforeAndAfter
-class SingleLevelAggregateHashMapSuite extends DataFrameAggregateSuite with BeforeAndAfter {
+import org.apache.spark.SparkConf
- protected override def beforeAll(): Unit = {
- sparkConf.set("spark.sql.codegen.fallback", "false")
- sparkConf.set("spark.sql.codegen.aggregate.map.twolevel.enable", "false")
- super.beforeAll()
- }
+class SingleLevelAggregateHashMapSuite extends DataFrameAggregateSuite with BeforeAndAfter {
+ override protected def sparkConf: SparkConf = super.sparkConf
+ .set("spark.sql.codegen.fallback", "false")
+ .set("spark.sql.codegen.aggregate.map.twolevel.enable", "false")
// adding some checking after each test is run, assuring that the configs are not changed
// in test code
@@ -38,12 +37,9 @@ class SingleLevelAggregateHashMapSuite extends DataFrameAggregateSuite with Befo
}
class TwoLevelAggregateHashMapSuite extends DataFrameAggregateSuite with BeforeAndAfter {
-
- protected override def beforeAll(): Unit = {
- sparkConf.set("spark.sql.codegen.fallback", "false")
- sparkConf.set("spark.sql.codegen.aggregate.map.twolevel.enable", "true")
- super.beforeAll()
- }
+ override protected def sparkConf: SparkConf = super.sparkConf
+ .set("spark.sql.codegen.fallback", "false")
+ .set("spark.sql.codegen.aggregate.map.twolevel.enable", "true")
// adding some checking after each test is run, assuring that the configs are not changed
// in test code
@@ -55,15 +51,14 @@ class TwoLevelAggregateHashMapSuite extends DataFrameAggregateSuite with BeforeA
}
}
-class TwoLevelAggregateHashMapWithVectorizedMapSuite extends DataFrameAggregateSuite with
-BeforeAndAfter {
+class TwoLevelAggregateHashMapWithVectorizedMapSuite
+ extends DataFrameAggregateSuite
+ with BeforeAndAfter {
- protected override def beforeAll(): Unit = {
- sparkConf.set("spark.sql.codegen.fallback", "false")
- sparkConf.set("spark.sql.codegen.aggregate.map.twolevel.enable", "true")
- sparkConf.set("spark.sql.codegen.aggregate.map.vectorized.enable", "true")
- super.beforeAll()
- }
+ override protected def sparkConf: SparkConf = super.sparkConf
+ .set("spark.sql.codegen.fallback", "false")
+ .set("spark.sql.codegen.aggregate.map.twolevel.enable", "true")
+ .set("spark.sql.codegen.aggregate.map.vectorized.enable", "true")
// adding some checking after each test is run, assuring that the configs are not changed
// in test code
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/DatasetSerializerRegistratorSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/DatasetSerializerRegistratorSuite.scala
index 92c5656f65..68f7de047b 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/DatasetSerializerRegistratorSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/DatasetSerializerRegistratorSuite.scala
@@ -20,9 +20,9 @@ package org.apache.spark.sql
import com.esotericsoftware.kryo.{Kryo, Serializer}
import com.esotericsoftware.kryo.io.{Input, Output}
+import org.apache.spark.SparkConf
import org.apache.spark.serializer.KryoRegistrator
import org.apache.spark.sql.test.SharedSQLContext
-import org.apache.spark.sql.test.TestSparkSession
/**
* Test suite to test Kryo custom registrators.
@@ -30,12 +30,10 @@ import org.apache.spark.sql.test.TestSparkSession
class DatasetSerializerRegistratorSuite extends QueryTest with SharedSQLContext {
import testImplicits._
- /**
- * Initialize the [[TestSparkSession]] with a [[KryoRegistrator]].
- */
- protected override def beforeAll(): Unit = {
- sparkConf.set("spark.kryo.registrator", TestRegistrator().getClass.getCanonicalName)
- super.beforeAll()
+
+ override protected def sparkConf: SparkConf = {
+ // Make sure we use the KryoRegistrator
+ super.sparkConf.set("spark.kryo.registrator", TestRegistrator().getClass.getCanonicalName)
}
test("Kryo registrator") {
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/DataSourceScanExecRedactionSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/DataSourceScanExecRedactionSuite.scala
index 05a2b2c862..f7f1ccea28 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/execution/DataSourceScanExecRedactionSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/DataSourceScanExecRedactionSuite.scala
@@ -18,22 +18,17 @@ package org.apache.spark.sql.execution
import org.apache.hadoop.fs.Path
+import org.apache.spark.SparkConf
import org.apache.spark.sql.QueryTest
import org.apache.spark.sql.test.SharedSQLContext
-import org.apache.spark.util.Utils
/**
* Suite that tests the redaction of DataSourceScanExec
*/
class DataSourceScanExecRedactionSuite extends QueryTest with SharedSQLContext {
- import Utils._
-
- override def beforeAll(): Unit = {
- sparkConf.set("spark.redaction.string.regex",
- "file:/[\\w_]+")
- super.beforeAll()
- }
+ override protected def sparkConf: SparkConf = super.sparkConf
+ .set("spark.redaction.string.regex", "file:/[\\w_]+")
test("treeString is redacted") {
withTempDir { dir =>
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/FileSourceStrategySuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/FileSourceStrategySuite.scala
index f36162858b..8703fe96e5 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/FileSourceStrategySuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/FileSourceStrategySuite.scala
@@ -42,7 +42,7 @@ import org.apache.spark.util.Utils
class FileSourceStrategySuite extends QueryTest with SharedSQLContext with PredicateHelper {
import testImplicits._
- protected override val sparkConf = new SparkConf().set("spark.default.parallelism", "1")
+ protected override def sparkConf = super.sparkConf.set("spark.default.parallelism", "1")
test("unpartitioned table, single partition") {
val table =
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/CompactibleFileStreamLogSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/CompactibleFileStreamLogSuite.scala
index 20ac06f048..3d480b148d 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/CompactibleFileStreamLogSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/CompactibleFileStreamLogSuite.scala
@@ -28,8 +28,8 @@ import org.apache.spark.sql.test.SharedSQLContext
class CompactibleFileStreamLogSuite extends SparkFunSuite with SharedSQLContext {
/** To avoid caching of FS objects */
- override protected val sparkConf =
- new SparkConf().set(s"spark.hadoop.fs.$scheme.impl.disable.cache", "true")
+ override protected def sparkConf =
+ super.sparkConf.set(s"spark.hadoop.fs.$scheme.impl.disable.cache", "true")
import CompactibleFileStreamLog._
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/HDFSMetadataLogSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/HDFSMetadataLogSuite.scala
index 662c4466b2..7689bc03a4 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/HDFSMetadataLogSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/HDFSMetadataLogSuite.scala
@@ -38,8 +38,8 @@ import org.apache.spark.util.UninterruptibleThread
class HDFSMetadataLogSuite extends SparkFunSuite with SharedSQLContext {
/** To avoid caching of FS objects */
- override protected val sparkConf =
- new SparkConf().set(s"spark.hadoop.fs.$scheme.impl.disable.cache", "true")
+ override protected def sparkConf =
+ super.sparkConf.set(s"spark.hadoop.fs.$scheme.impl.disable.cache", "true")
private implicit def toOption[A](a: A): Option[A] = Option(a)
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/test/SharedSQLContext.scala b/sql/core/src/test/scala/org/apache/spark/sql/test/SharedSQLContext.scala
index 3d76e05f61..81c69a338a 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/test/SharedSQLContext.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/test/SharedSQLContext.scala
@@ -30,7 +30,9 @@ import org.apache.spark.sql.{SparkSession, SQLContext}
*/
trait SharedSQLContext extends SQLTestUtils with BeforeAndAfterEach with Eventually {
- protected val sparkConf = new SparkConf()
+ protected def sparkConf = {
+ new SparkConf().set("spark.hadoop.fs.file.impl", classOf[DebugFilesystem].getName)
+ }
/**
* The [[TestSparkSession]] to use for all tests in this suite.
@@ -51,8 +53,7 @@ trait SharedSQLContext extends SQLTestUtils with BeforeAndAfterEach with Eventua
protected implicit def sqlContext: SQLContext = _spark.sqlContext
protected def createSparkSession: TestSparkSession = {
- new TestSparkSession(
- sparkConf.set("spark.hadoop.fs.file.impl", classOf[DebugFilesystem].getName))
+ new TestSparkSession(sparkConf)
}
/**