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
Fix test compile after resolving merge conflicts
  • Loading branch information
Andrew Or committed Aug 11, 2015
commit f5619f8201f8dff2b335d42e9fa1b303735de4a8
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@

package org.apache.spark.sql.execution.datasources.parquet

import org.apache.spark.sql.test.TestSQLContext
import org.apache.spark.sql.{DataFrame, Row, SQLContext}
import org.apache.spark.sql.{DataFrame, Row}

class ParquetProtobufCompatibilitySuite extends ParquetCompatibilityTest {
override def sqlContext: SQLContext = TestSQLContext

private def readParquetProtobufFile(name: String): DataFrame = {
val url = Thread.currentThread().getContextClassLoader.getResource(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@

package org.apache.spark.sql.execution.joins

import org.apache.spark.sql.{SQLConf, execution, Row, DataFrame}
import org.apache.spark.sql.catalyst.expressions.Expression
import org.apache.spark.sql.catalyst.planning.ExtractEquiJoinKeys
import org.apache.spark.sql.catalyst.plans.Inner
import org.apache.spark.sql.catalyst.plans.logical.Join
import org.apache.spark.sql.test.SQLTestUtils
import org.apache.spark.sql.types.{IntegerType, StringType, StructType}
import org.apache.spark.sql.{SQLConf, execution, Row, DataFrame}
import org.apache.spark.sql.catalyst.expressions.Expression
import org.apache.spark.sql.execution._
import org.apache.spark.sql.types.{IntegerType, StringType, StructType}

class InnerJoinSuite extends SparkPlanTest with SQLTestUtils {
class InnerJoinSuite extends SparkPlanTest {

private def testInnerJoin(
testName: String,
Expand Down Expand Up @@ -107,23 +106,25 @@ class InnerJoinSuite extends SparkPlanTest with SQLTestUtils {
}

{
val upperCaseData = sqlContext.createDataFrame(sqlContext.sparkContext.parallelize(Seq(
Row(1, "A"),
Row(2, "B"),
Row(3, "C"),
Row(4, "D"),
Row(5, "E"),
Row(6, "F"),
Row(null, "G")
)), new StructType().add("N", IntegerType).add("L", StringType))

val lowerCaseData = sqlContext.createDataFrame(sqlContext.sparkContext.parallelize(Seq(
Row(1, "a"),
Row(2, "b"),
Row(3, "c"),
Row(4, "d"),
Row(null, "e")
)), new StructType().add("n", IntegerType).add("l", StringType))
lazy val upperCaseData = ctx.createDataFrame(
ctx.sparkContext.parallelize(Seq(
Row(1, "A"),
Row(2, "B"),
Row(3, "C"),
Row(4, "D"),
Row(5, "E"),
Row(6, "F"),
Row(null, "G")
)), new StructType().add("N", IntegerType).add("L", StringType))

lazy val lowerCaseData = ctx.createDataFrame(
ctx.sparkContext.parallelize(Seq(
Row(1, "a"),
Row(2, "b"),
Row(3, "c"),
Row(4, "d"),
Row(null, "e")
)), new StructType().add("n", IntegerType).add("l", StringType))

testInnerJoin(
"inner join, one match per row",
Expand All @@ -139,42 +140,44 @@ class InnerJoinSuite extends SparkPlanTest with SQLTestUtils {
)
}

private val testData2 = Seq(
(1, 1),
(1, 2),
(2, 1),
(2, 2),
(3, 1),
(3, 2)
).toDF("a", "b")

{
val left = testData2.where("a = 1")
val right = testData2.where("a = 1")
testInnerJoin(
"inner join, multiple matches",
left,
right,
(left.col("a") === right.col("a")).expr,
Seq(
(1, 1, 1, 1),
(1, 1, 1, 2),
(1, 2, 1, 1),
(1, 2, 1, 2)
lazy val testData2 = Seq(
(1, 1),
(1, 2),
(2, 1),
(2, 2),
(3, 1),
(3, 2)
).toDF("a", "b")

{
lazy val left = testData2.where("a = 1")
lazy val right = testData2.where("a = 1")
testInnerJoin(
"inner join, multiple matches",
left,
right,
(left.col("a") === right.col("a")).expr,
Seq(
(1, 1, 1, 1),
(1, 1, 1, 2),
(1, 2, 1, 1),
(1, 2, 1, 2)
)
)
)
}
}

{
val left = testData2.where("a = 1")
val right = testData2.where("a = 2")
testInnerJoin(
"inner join, no matches",
left,
right,
(left.col("a") === right.col("a")).expr,
Seq.empty
)
{
lazy val left = testData2.where("a = 1")
lazy val right = testData2.where("a = 2")
testInnerJoin(
"inner join, no matches",
left,
right,
(left.col("a") === right.col("a")).expr,
Seq.empty
)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package org.apache.spark.sql.execution.joins

import org.apache.spark.sql.{DataFrame, Row, SQLConf}
import org.apache.spark.sql.catalyst.planning.ExtractEquiJoinKeys
import org.apache.spark.sql.catalyst.plans._
import org.apache.spark.sql.catalyst.plans.logical.Join
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.plans._
import org.apache.spark.sql.execution.{EnsureRequirements, joins, SparkPlan, SparkPlanTest}
import org.apache.spark.sql.types.{IntegerType, DoubleType, StructType}

Expand Down Expand Up @@ -53,7 +53,7 @@ class OuterJoinSuite extends SparkPlanTest {
Row(null, null)
)), new StructType().add("c", IntegerType).add("d", DoubleType))

private val condition = {
private lazy val condition = {
And((left.col("a") === right.col("c")).expr,
LessThan(left.col("b").expr, right.col("d").expr))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ import org.apache.spark.sql._
import org.apache.spark.sql.test.SQLTestUtils


abstract class DataSourceTest extends QueryTest with BeforeAndAfter with SQLTestUtils {
private[sql] abstract class DataSourceTest extends AbstractDataSourceTest with SQLTestUtils

private[sql] abstract class AbstractDataSourceTest extends QueryTest with BeforeAndAfter {
protected def _sqlContext: SQLContext

// We want to test some edge cases.
protected lazy val caseInsensitiveContext: SQLContext = {
val ctx = new SQLContext(sqlContext.sparkContext)
val ctx = new SQLContext(_sqlContext.sparkContext)
ctx.setConf(SQLConf.CASE_SENSITIVE, false)
ctx
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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.hive.test

import org.apache.spark.sql.sources.AbstractDataSourceTest


/**
* An equivalent of [[org.apache.spark.sql.sources.DataSourceTest]], but for hive tests.
*/
private[hive] abstract class HiveDataSourceTest
extends AbstractDataSourceTest
with HiveTestUtils
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.spark.sql.hive.test

import org.apache.spark.sql.parquet.AbstractParquetCompatibilityTest
import org.apache.spark.sql.execution.datasources.parquet.AbstractParquetCompatibilityTest

/**
* Helper class for testing Parquet compatibility in hive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.spark.sql.hive.test

import org.apache.spark.sql.parquet.AbstractParquetTest
import org.apache.spark.sql.execution.datasources.parquet.AbstractParquetTest

/**
* Helper trait for Parquet tests analogous to [[org.apache.spark.sql.parquet.ParquetTest]].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import java.io.File
import org.apache.spark.{Logging, SparkFunSuite}
import org.apache.spark.sql.{Row, SaveMode}
import org.apache.spark.sql.hive.client.{ExternalTable, ManagedTable}
import org.apache.spark.sql.hive.test.HiveTestUtils
import org.apache.spark.sql.sources.DataSourceTest
import org.apache.spark.sql.hive.test.{HiveDataSourceTest, HiveTestUtils}
import org.apache.spark.sql.test.ExamplePointUDT
import org.apache.spark.sql.types.StructType

Expand Down Expand Up @@ -51,8 +50,10 @@ class HiveMetastoreCatalogSuite extends SparkFunSuite with HiveTestUtils with Lo
}
}

class DataSourceWithHiveMetastoreCatalogSuite extends DataSourceTest with HiveTestUtils {
private val testDF = (1 to 2).map(i => (i, s"val_$i")).toDF("d1", "d2").coalesce(1)
class DataSourceWithHiveMetastoreCatalogSuite extends HiveDataSourceTest {
import testImplicits._

private lazy val testDF = (1 to 2).map(i => (i, s"val_$i")).toDF("d1", "d2").coalesce(1)

Seq(
"parquet" -> (
Expand All @@ -75,7 +76,7 @@ class DataSourceWithHiveMetastoreCatalogSuite extends DataSourceTest with HiveTe
.format(provider)
.saveAsTable("t")

val hiveTable = catalog.client.getTable("default", "t")
val hiveTable = ctx.catalog.client.getTable("default", "t")
assert(hiveTable.inputFormat === Some(inputFormat))
assert(hiveTable.outputFormat === Some(outputFormat))
assert(hiveTable.serde === Some(serde))
Expand All @@ -87,8 +88,8 @@ class DataSourceWithHiveMetastoreCatalogSuite extends DataSourceTest with HiveTe
assert(columns.map(_.name) === Seq("d1", "d2"))
assert(columns.map(_.hiveType) === Seq("int", "string"))

checkAnswer(table("t"), testDF)
assert(runSqlHive("SELECT * FROM t") === Seq("1\tval_1", "2\tval_2"))
checkAnswer(ctx.table("t"), testDF)
assert(ctx.runSqlHive("SELECT * FROM t") === Seq("1\tval_1", "2\tval_2"))
}
}

Expand All @@ -104,7 +105,7 @@ class DataSourceWithHiveMetastoreCatalogSuite extends DataSourceTest with HiveTe
.option("path", path.toString)
.saveAsTable("t")

val hiveTable = catalog.client.getTable("default", "t")
val hiveTable = ctx.catalog.client.getTable("default", "t")
assert(hiveTable.inputFormat === Some(inputFormat))
assert(hiveTable.outputFormat === Some(outputFormat))
assert(hiveTable.serde === Some(serde))
Expand All @@ -116,8 +117,8 @@ class DataSourceWithHiveMetastoreCatalogSuite extends DataSourceTest with HiveTe
assert(columns.map(_.name) === Seq("d1", "d2"))
assert(columns.map(_.hiveType) === Seq("int", "string"))

checkAnswer(table("t"), testDF)
assert(runSqlHive("SELECT * FROM t") === Seq("1\tval_1", "2\tval_2"))
checkAnswer(ctx.table("t"), testDF)
assert(ctx.runSqlHive("SELECT * FROM t") === Seq("1\tval_1", "2\tval_2"))
}
}
}
Expand All @@ -127,13 +128,13 @@ class DataSourceWithHiveMetastoreCatalogSuite extends DataSourceTest with HiveTe
withTable("t") {
val path = dir.getCanonicalPath

sql(
ctx.sql(
s"""CREATE TABLE t USING $provider
|OPTIONS (path '$path')
|AS SELECT 1 AS d1, "val_1" AS d2
""".stripMargin)

val hiveTable = catalog.client.getTable("default", "t")
val hiveTable = ctx.catalog.client.getTable("default", "t")
assert(hiveTable.inputFormat === Some(inputFormat))
assert(hiveTable.outputFormat === Some(outputFormat))
assert(hiveTable.serde === Some(serde))
Expand All @@ -146,8 +147,8 @@ class DataSourceWithHiveMetastoreCatalogSuite extends DataSourceTest with HiveTe
assert(columns.map(_.name) === Seq("d1", "d2"))
assert(columns.map(_.hiveType) === Seq("int", "string"))

checkAnswer(table("t"), Row(1, "val_1"))
assert(runSqlHive("SELECT * FROM t") === Seq("1\tval_1"))
checkAnswer(ctx.table("t"), Row(1, "val_1"))
assert(ctx.runSqlHive("SELECT * FROM t") === Seq("1\tval_1"))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@

package org.apache.spark.sql.hive

<<<<<<< HEAD
import org.apache.spark.sql.hive.test.HiveParquetTest
=======
import org.apache.spark.sql.hive.test.TestHive
import org.apache.spark.sql.execution.datasources.parquet.ParquetTest
>>>>>>> 3c9802d9400bea802984456683b2736a450ee17e
import org.apache.spark.sql.{QueryTest, Row}
import org.apache.spark.sql.hive.test.HiveParquetTest

case class Cases(lower: String, UPPER: String)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ class MetastoreDataSourcesSuite
// Drop table will also delete the data.
ctx.sql("DROP TABLE savedJsonTable")
intercept[IOException] {
ctx.read.json(catalog.hiveDefaultTableFilePath("savedJsonTable"))
ctx.read.json(ctx.catalog.hiveDefaultTableFilePath("savedJsonTable"))
}
}

Expand Down
Loading