Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
16ca7ac
It compiles!!
Aug 4, 2015
5e6a20c
Refactor SQLTestUtils to reduce duplication
Aug 5, 2015
d1d1449
Remove HiveTest singleton
Aug 5, 2015
d4aafb1
Avoid the need to switch to HiveContexts
Aug 5, 2015
6345cee
Clean up JsonSuite
Aug 5, 2015
68ac6fe
Rename the test traits properly
Aug 5, 2015
b15fdc6
Stop SparkContext in Java SQL tests
Aug 5, 2015
0d74a72
Load test data early in case tables are accessed by name
Aug 5, 2015
eee415d
Refactor implicits into SQLTestUtils
Aug 10, 2015
55d0b1b
Fix Java not serializable exception in tests
Aug 10, 2015
4f59bee
Fix DataSourceTest et al.
Aug 10, 2015
88d4f16
Fix hive tests to use the same pattern
Aug 11, 2015
5fe4bfb
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 11, 2015
c4a22bc
Fix compile after resolving merge conflicts
Aug 11, 2015
d9a8390
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 11, 2015
f5619f8
Fix test compile after resolving merge conflicts
Aug 11, 2015
9395cfa
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 11, 2015
c51b3d8
Fix OuterJoinSuite
Aug 11, 2015
997715e
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 11, 2015
1400770
Fix style
Aug 11, 2015
c92a3b0
Fix MiMa
Aug 11, 2015
4debedf
Clean up inheritance in test util traits
Aug 11, 2015
ca87dda
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 11, 2015
1cf53ad
Create new context in SBT console by default
Aug 11, 2015
bc5c999
Fix SemiJoinSuite
Aug 12, 2015
19fd6c3
Fix InnerJoinSuite
Aug 12, 2015
e1e513e
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 12, 2015
1e4c321
Address comments
Aug 12, 2015
54848e2
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 12, 2015
94f9c77
Revert the removal of some BeforeAndAfters
Aug 12, 2015
bec7d28
Fix a hive test + minor format updates
Aug 12, 2015
24c086d
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 12, 2015
561eacc
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 12, 2015
aaba277
Fix places where we override before / after alls
Aug 12, 2015
aac8f7f
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 12, 2015
40959bb
Fix test
Aug 12, 2015
55d6624
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 12, 2015
4ed58c8
Revert a few merge-conflict-induced unintentional changes
Aug 12, 2015
0ce5638
Minor updates
Aug 13, 2015
814df2f
Add back singletons but deprecate them
Aug 13, 2015
099c74f
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 13, 2015
451fa37
Use consistent name for added back singletons
Aug 13, 2015
9ea7f7c
Fix style
Aug 13, 2015
ddc4b05
Revert "Use consistent name for added back singletons"
Aug 13, 2015
ece3a81
Remove TestSQLContext, but keep TestHive
Aug 13, 2015
94cc3b5
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 13, 2015
8d69bf8
Fix test
Aug 13, 2015
7a0b1ef
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 13, 2015
b58ae73
Fix tests
Aug 13, 2015
828144f
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 13, 2015
c4d44c9
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 13, 2015
48af8e4
Fix another before / after alls
Aug 13, 2015
0606c82
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 13, 2015
f599bbc
Revert all Hive related changes
Aug 13, 2015
aed7fc7
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 13, 2015
d85a6d8
Add a shorthand for sqlContext.sql / ctx.sql
Aug 13, 2015
0b60325
Fix hive test compile
Aug 13, 2015
821ea67
Merge branch 'master' of github.com:apache/spark into sql-tests-refactor
Aug 13, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address comments
  • Loading branch information
Andrew Or committed Aug 12, 2015
commit 1e4c32115161399f5871e5327c61e2bbec00e7ed
4 changes: 4 additions & 0 deletions sql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ import org.apache.spark.sql.execution
import org.apache.spark.sql.functions._
import org.apache.spark.sql.hive._
import org.apache.spark.sql.types._
sc: org.apache.spark.SparkContext = org.apache.spark.SparkContext@27fc0441
hc: org.apache.spark.sql.hive.HiveContext = org.apache.spark.sql.hive.HiveContext@127b5be9
import hc.implicits._
import hc._
Type in expressions to have them evaluated.
Type :help for more information.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@

package org.apache.spark.sql.catalyst.analysis

import org.scalatest.BeforeAndAfter

import org.apache.spark.SparkFunSuite
import org.apache.spark.sql.AnalysisException
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.plans.logical._
import org.apache.spark.sql.catalyst.plans.Inner
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.dsl.expressions._
import org.apache.spark.sql.catalyst.dsl.plans._
import org.apache.spark.sql.types._
Expand All @@ -42,7 +38,7 @@ case class UnresolvedTestPlan() extends LeafNode {
override def output: Seq[Attribute] = Nil
}

class AnalysisErrorSuite extends AnalysisTest with BeforeAndAfter {
class AnalysisErrorSuite extends AnalysisTest {
import TestRelations._

def errorTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.sql.*;
import static org.apache.spark.sql.functions.*;
import org.apache.spark.sql.test.TestSQLContext;
import org.apache.spark.sql.types.*;
import static org.apache.spark.sql.functions.*;

public class JavaDataFrameSuite {
private transient JavaSparkContext jsc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ class ListTablesSuite extends QueryTest with BeforeAndAfter with SharedSQLContex

private lazy val df = (1 to 10).map(i => (i, s"str$i")).toDF("key", "value")

before {
override def beforeAll(): Unit = {
super.beforeAll()
df.registerTempTable("ListTablesSuiteTable")
}

after {
ctx.catalog.unregisterTable(Seq("ListTablesSuiteTable"))
override def afterAll(): Unit = {
try {
ctx.catalog.unregisterTable(Seq("ListTablesSuiteTable"))
} finally {
afterAll()
}
}

test("get all tables") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ import org.apache.spark.sql.test.SharedSQLContext
class SQLContextSuite extends SparkFunSuite with SharedSQLContext {

override def afterAll(): Unit = {
SQLContext.setLastInstantiatedContext(ctx)
super.afterAll()
try {
SQLContext.setLastInstantiatedContext(ctx)
} finally {
super.afterAll()
}
}

test("getOrCreate instantiates SQLContext") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import org.apache.spark.sql._
import org.apache.spark.sql.test.SharedSQLContext
import org.apache.spark.sql.test.SQLTestData._

class PartitionBatchPruningSuite extends SparkFunSuite with SharedSQLContext with BeforeAndAfter {
class PartitionBatchPruningSuite extends SparkFunSuite with SharedSQLContext {
import testImplicits._

private lazy val originalColumnBatchSize = ctx.conf.columnBatchSize
Expand All @@ -45,20 +45,17 @@ class PartitionBatchPruningSuite extends SparkFunSuite with SharedSQLContext wit
ctx.setConf(SQLConf.IN_MEMORY_PARTITION_PRUNING, true)
// Enable in-memory table scan accumulators
ctx.setConf("spark.sql.inMemoryTableScanStatistics.enable", "true")
}

override protected def afterAll(): Unit = {
ctx.setConf(SQLConf.COLUMN_BATCH_SIZE, originalColumnBatchSize)
ctx.setConf(SQLConf.IN_MEMORY_PARTITION_PRUNING, originalInMemoryPartitionPruning)
super.afterAll()
}

before {
ctx.cacheTable("pruningData")
}

after {
ctx.uncacheTable("pruningData")
override protected def afterAll(): Unit = {
try {
ctx.setConf(SQLConf.COLUMN_BATCH_SIZE, originalColumnBatchSize)
ctx.setConf(SQLConf.IN_MEMORY_PARTITION_PRUNING, originalInMemoryPartitionPruning)
ctx.uncacheTable("pruningData")
} finally {
super.afterAll()
}
}

// Comparisons
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ class TungstenSortSuite extends SparkPlanTest with SharedSQLContext {
}

override def afterAll(): Unit = {
ctx.conf.setConf(SQLConf.CODEGEN_ENABLED, SQLConf.CODEGEN_ENABLED.defaultValue.get)
super.afterAll()
try {
ctx.conf.setConf(SQLConf.CODEGEN_ENABLED, SQLConf.CODEGEN_ENABLED.defaultValue.get)
} finally {
super.afterAll()
}
}

test("sort followed by limit") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ package org.apache.spark.sql.sources

import java.io.{File, IOException}

import org.scalatest.BeforeAndAfter

import org.apache.spark.sql.AnalysisException
import org.apache.spark.sql.execution.datasources.DDLException
import org.apache.spark.sql.test.SharedSQLContext
import org.apache.spark.util.Utils


class CreateTableAsSelectSuite extends DataSourceTest with SharedSQLContext with BeforeAndAfter {
class CreateTableAsSelectSuite extends DataSourceTest with SharedSQLContext {
private lazy val sparkContext = caseInsensitiveContext.sparkContext
private var path: File = null

Expand All @@ -39,12 +37,12 @@ class CreateTableAsSelectSuite extends DataSourceTest with SharedSQLContext with
}

override def afterAll(): Unit = {
caseInsensitiveContext.dropTempTable("jt")
super.afterAll()
}

after {
Utils.deleteRecursively(path)
try {
caseInsensitiveContext.dropTempTable("jt")
Utils.deleteRecursively(path)
} finally {
super.afterAll()
}
}

test("CREATE TEMPORARY TABLE AS SELECT") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ case class SimpleDDLScan(from: Int, to: Int, table: String)(@transient val sqlCo
}
}

class DDLTestSuite extends DataSourceTest with SharedSQLContext with BeforeAndAfter {
class DDLTestSuite extends DataSourceTest with SharedSQLContext {

before {
override def beforeAll(): Unit = {
super.beforeAll()
caseInsensitiveContext.sql(
"""
|CREATE TEMPORARY TABLE ddlPeople
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ package org.apache.spark.sql.sources

import scala.language.existentials

import org.scalatest.BeforeAndAfter

import org.apache.spark.rdd.RDD
import org.apache.spark.sql._
import org.apache.spark.sql.test.SharedSQLContext
Expand Down Expand Up @@ -99,9 +97,10 @@ object FiltersPushed {
var list: Seq[Filter] = Nil
}

class FilteredScanSuite extends DataSourceTest with SharedSQLContext with BeforeAndAfter {
class FilteredScanSuite extends DataSourceTest with SharedSQLContext {

before {
override def beforeAll(): Unit = {
super.beforeAll()
caseInsensitiveContext.sql(
"""
|CREATE TEMPORARY TABLE oneToTenFiltered
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ class InsertSuite extends DataSourceTest with SharedSQLContext {
}

override def afterAll(): Unit = {
caseInsensitiveContext.dropTempTable("jsonTable")
caseInsensitiveContext.dropTempTable("jt")
Utils.deleteRecursively(path)
super.afterAll()
try {
caseInsensitiveContext.dropTempTable("jsonTable")
caseInsensitiveContext.dropTempTable("jt")
Utils.deleteRecursively(path)
} finally {
super.afterAll()
}
}

test("Simple INSERT OVERWRITE a JSONRelation") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ package org.apache.spark.sql.sources

import scala.language.existentials

import org.scalatest.BeforeAndAfter

import org.apache.spark.rdd.RDD
import org.apache.spark.sql._
import org.apache.spark.sql.test.SharedSQLContext
Expand Down Expand Up @@ -54,9 +52,10 @@ case class SimplePrunedScan(from: Int, to: Int)(@transient val sqlContext: SQLCo
}
}

class PrunedScanSuite extends DataSourceTest with SharedSQLContext with BeforeAndAfter {
class PrunedScanSuite extends DataSourceTest with SharedSQLContext {

before {
override def beforeAll(): Unit = {
super.beforeAll()
caseInsensitiveContext.sql(
"""
|CREATE TEMPORARY TABLE oneToTenPruned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ package org.apache.spark.sql.sources

import java.io.File

import org.scalatest.BeforeAndAfter

import org.apache.spark.sql.{AnalysisException, SaveMode, SQLConf, DataFrame}
import org.apache.spark.sql.test.SharedSQLContext
import org.apache.spark.sql.types._
import org.apache.spark.util.Utils

class SaveLoadSuite extends DataSourceTest with SharedSQLContext with BeforeAndAfter {
class SaveLoadSuite extends DataSourceTest with SharedSQLContext {
private lazy val sparkContext = caseInsensitiveContext.sparkContext
private var originalDefaultSource: String = null
private var path: File = null
Expand All @@ -45,13 +43,12 @@ class SaveLoadSuite extends DataSourceTest with SharedSQLContext with BeforeAndA
}

override def afterAll(): Unit = {
caseInsensitiveContext.conf.setConf(SQLConf.DEFAULT_DATA_SOURCE_NAME, originalDefaultSource)
super.afterAll()
}

after {
caseInsensitiveContext.conf.setConf(SQLConf.DEFAULT_DATA_SOURCE_NAME, originalDefaultSource)
Utils.deleteRecursively(path)
try {
caseInsensitiveContext.conf.setConf(SQLConf.DEFAULT_DATA_SOURCE_NAME, originalDefaultSource)
Utils.deleteRecursively(path)
} finally {
super.afterAll()
}
}

def checkLoad(expectedDF: DataFrame = df, tbl: String = "jsonTable"): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ package org.apache.spark.sql.sources
import java.nio.charset.StandardCharsets
import java.sql.{Date, Timestamp}

import org.scalatest.BeforeAndAfter

import org.apache.spark.rdd.RDD
import org.apache.spark.sql._
import org.apache.spark.sql.test.SharedSQLContext
Expand Down Expand Up @@ -98,7 +96,7 @@ case class AllDataTypesScan(
}
}

class TableScanSuite extends DataSourceTest with SharedSQLContext with BeforeAndAfter {
class TableScanSuite extends DataSourceTest with SharedSQLContext {
private lazy val tableWithSchemaExpected = (1 to 10).map { i =>
Row(
s"str_$i",
Expand All @@ -123,7 +121,8 @@ class TableScanSuite extends DataSourceTest with SharedSQLContext with BeforeAnd
Row(Seq(s"str_$i", s"str_${i + 1}"), Row(Seq(Date.valueOf(s"1970-01-${i + 1}")))))
}.toSeq

before {
override def beforeAll(): Unit = {
super.beforeAll()
caseInsensitiveContext.sql(
"""
|CREATE TEMPORARY TABLE oneToTen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private[sql] trait SharedSQLContext extends SQLTestUtils {
if (_ctx == null) {
_ctx = new TestSQLContext
}
// Ensure we have initialized the context before calling parent code
super.beforeAll()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ private[spark] trait SharedHiveContext extends SQLTestUtils {
if (_ctx == null) {
_ctx = new TestHiveContext
}
// Ensure we have initialized the context before calling parent code
super.beforeAll()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
import org.apache.spark.sql.*;
import org.apache.spark.sql.expressions.Window;
import org.apache.spark.sql.expressions.UserDefinedAggregateFunction;
import static org.apache.spark.sql.functions.*;
import org.apache.spark.sql.hive.HiveContext;
import org.apache.spark.sql.hive.test.TestHiveContext;
import test.org.apache.spark.sql.hive.aggregate.MyDoubleSum;
import static org.apache.spark.sql.functions.*;

public class JavaDataFrameSuite {
private transient JavaSparkContext sc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import org.apache.spark.sql.{AnalysisException, QueryTest}
class ErrorPositionSuite extends QueryTest with BeforeAndAfter with SharedHiveContext {
import testImplicits._

before {
override def beforeAll(): Unit = {
super.beforeAll()
Seq((1, 1, 1)).toDF("a", "a", "b").registerTempTable("dupAttributes")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import org.apache.spark.sql.test.SQLTestData.TestData
import org.apache.spark.sql.types._
import org.apache.spark.util.Utils

case class ThreeCloumntable(key: Int, value: String, key1: String)
case class ThreeColumnTable(key: Int, value: String, key1: String)

class InsertIntoHiveTableSuite extends QueryTest with BeforeAndAfter with SharedHiveContext {
import testImplicits._

private val _testData = ctx.sparkContext.parallelize(
private lazy val _testData = ctx.sparkContext.parallelize(
(1 to 100).map(i => TestData(i, i.toString))).toDF()

before {
Expand Down Expand Up @@ -217,7 +217,7 @@ class InsertIntoHiveTableSuite extends QueryTest with BeforeAndAfter with Shared
testData.registerTempTable("testData")

val testDatawithNull = ctx.sparkContext.parallelize(
(1 to 10).map(i => ThreeCloumntable(i, i.toString, null))).toDF()
(1 to 10).map(i => ThreeColumnTable(i, i.toString, null))).toDF()

val tmpDir = Utils.createTempDir()
ctx.sql(
Expand Down
Loading