Skip to content
Closed
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 @@ -344,12 +344,16 @@ case class InsertIntoHiveTable(
writer.commitJob()
}

override def execute() = result

/**
* Inserts all the rows in the table into Hive. Row objects are properly serialized with the
* `org.apache.hadoop.hive.serde2.SerDe` and the
* `org.apache.hadoop.mapred.OutputFormat` provided by the table definition.
*
* Note: this is run once and then kept to avoid double insertions.
*/
def execute() = {
private lazy val result: RDD[Row] = {
val childRdd = child.execute()
assert(childRdd != null)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ import org.apache.spark.sql.{SchemaRDD, execution, Row}
*/
class HiveQuerySuite extends HiveComparisonTest {

test("CREATE TABLE AS runs once") {
hql("CREATE TABLE foo AS SELECT 1 FROM src LIMIT 1").collect()
assert(hql("SELECT COUNT(*) FROM foo").collect().head.getLong(0) === 1,
"Incorrect number of rows in created table")
}

createQueryTest("between",
"SELECT * FROM src WHERE key Between 1 and 2")

Expand Down