Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr/374 #1

Merged
merged 5 commits into from
Apr 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class SchemaRDD(
def baseSchemaRDD = this

// =========================================================================================
// RDD functions: Copy the interal row representation so we present immutable data to users.
// RDD functions: Copy the internal row representation so we present immutable data to users.
// =========================================================================================

override def compute(split: Partition, context: TaskContext): Iterator[Row] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ case class Exchange(newPartitioning: Partitioning, child: SparkPlan) extends Una
shuffled.map(_._1)

case SinglePartition =>
child.execute().coalesce(1, shuffle = true)
val rdd = child.execute().mapPartitions { iter =>
val mutablePair = new MutablePair[Null, Row]()
iter.map(r => mutablePair.update(null, r))
}
val partitioner = new HashPartitioner(1)
val shuffled = new ShuffledRDD[Null, Row, MutablePair[Null, Row]](rdd, partitioner)
shuffled.setSerializer(new SparkSqlSerializer(new SparkConf(false)))
shuffled.map(_._2)

case _ => sys.error(s"Exchange not implemented for $newPartitioning")
// TODO: Handle BroadcastPartitioning.
Expand Down
10 changes: 4 additions & 6 deletions sql/hive/src/main/scala/org/apache/spark/sql/hive/TestHive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,6 @@ class TestHiveContext(sc: SparkContext) extends LocalHiveContext(sc) {
TestTable("src1",
"CREATE TABLE src1 (key INT, value STRING)".cmd,
s"LOAD DATA LOCAL INPATH '${getHiveFile("data/files/kv3.txt")}' INTO TABLE src1".cmd),
TestTable("dest1",
"CREATE TABLE IF NOT EXISTS dest1 (key INT, value STRING)".cmd),
TestTable("dest2",
"CREATE TABLE IF NOT EXISTS dest2 (key INT, value STRING)".cmd),
TestTable("dest3",
"CREATE TABLE IF NOT EXISTS dest3 (key INT, value STRING)".cmd),
TestTable("srcpart", () => {
runSqlHive(
"CREATE TABLE srcpart (key INT, value STRING) PARTITIONED BY (ds STRING, hr STRING)")
Expand Down Expand Up @@ -257,6 +251,7 @@ class TestHiveContext(sc: SparkContext) extends LocalHiveContext(sc) {

private val loadedTables = new collection.mutable.HashSet[String]

var cacheTables: Boolean = false
def loadTestTable(name: String) {
if (!(loadedTables contains name)) {
// Marks the table as loaded first to prevent infite mutually recursive table loading.
Expand All @@ -265,6 +260,9 @@ class TestHiveContext(sc: SparkContext) extends LocalHiveContext(sc) {
val createCmds =
testTables.get(name).map(_.commands).getOrElse(sys.error(s"Unknown test table $name"))
createCmds.foreach(_())

if (cacheTables)
cacheTable(name)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,7 @@ abstract class HiveComparisonTest
val quotes = "\"\"\""
queryList.zipWithIndex.map {
case (query, i) =>
s"""
|val q$i = $quotes$query$quotes.q
|q$i.stringResult()
""".stripMargin
s"""val q$i = hql($quotes$query$quotes); q$i.collect()"""
}.mkString("\n== Console version of this test ==\n", "\n", "\n")
}

Expand Down Expand Up @@ -287,7 +284,6 @@ abstract class HiveComparisonTest
|Error: ${e.getMessage}
|${stackTraceToString(e)}
|$queryString
|$consoleTestCase
""".stripMargin
stringToFile(
new File(hiveFailedDirectory, testCaseName),
Expand All @@ -313,8 +309,6 @@ abstract class HiveComparisonTest
|$query
|== HIVE - ${hive.size} row(s) ==
|${hive.mkString("\n")}
|
|$consoleTestCase
""".stripMargin
stringToFile(new File(failedDirectory, testCaseName), errorMessage + consoleTestCase)
fail(errorMessage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
package org.apache.spark.sql.hive.execution

import org.apache.spark.sql.hive.TestHive
import org.scalatest.BeforeAndAfter

class HiveInMemoryCompatibilitySuite extends HiveCompatibilitySuite with BeforeAndAfter {
override def beforeAll() {
TestHive.cacheTables = true
}

override def afterAll() {
TestHive.cacheTables = false
}
}

/**
* Runs the test cases that are included in the hive distribution.
Expand Down