aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgatorsmile <gatorsmile@gmail.com>2016-07-04 13:45:07 +0800
committerWenchen Fan <wenchen@databricks.com>2016-07-04 13:45:07 +0800
commit26283339786f38c50722a7488d0bca8573b9c352 (patch)
treedcb89ed135c3fa830c891f6aad17ca3f97df0d3e
parent8cdb81fa8264085b1bc04638b649b681ae871843 (diff)
downloadspark-26283339786f38c50722a7488d0bca8573b9c352.tar.gz
spark-26283339786f38c50722a7488d0bca8573b9c352.tar.bz2
spark-26283339786f38c50722a7488d0bca8573b9c352.zip
[SPARK-16358][SQL] Remove InsertIntoHiveTable From Logical Plan
#### What changes were proposed in this pull request? LogicalPlan `InsertIntoHiveTable` is useless. Thus, we can remove it from the code base. #### How was this patch tested? The existing test cases Author: gatorsmile <gatorsmile@gmail.com> Closes #14037 from gatorsmile/InsertIntoHiveTable.
-rw-r--r--sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala39
-rw-r--r--sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveStrategies.scala7
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala2
3 files changed, 1 insertions, 47 deletions
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala
index 2e0b5d59b5..151e4563a7 100644
--- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala
+++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala
@@ -372,12 +372,6 @@ private[hive] class HiveMetastoreCatalog(sparkSession: SparkSession) extends Log
if !r.hiveQlTable.isPartitioned && shouldConvertMetastoreParquet(r) =>
InsertIntoTable(convertToParquetRelation(r), partition, child, overwrite, ifNotExists)
- // Write path
- case InsertIntoHiveTable(r: MetastoreRelation, partition, child, overwrite, ifNotExists)
- // Inserting into partitioned table is not supported in Parquet data source (yet).
- if !r.hiveQlTable.isPartitioned && shouldConvertMetastoreParquet(r) =>
- InsertIntoTable(convertToParquetRelation(r), partition, child, overwrite, ifNotExists)
-
// Read path
case relation: MetastoreRelation if shouldConvertMetastoreParquet(relation) =>
val parquetRelation = convertToParquetRelation(relation)
@@ -416,12 +410,6 @@ private[hive] class HiveMetastoreCatalog(sparkSession: SparkSession) extends Log
if !r.hiveQlTable.isPartitioned && shouldConvertMetastoreOrc(r) =>
InsertIntoTable(convertToOrcRelation(r), partition, child, overwrite, ifNotExists)
- // Write path
- case InsertIntoHiveTable(r: MetastoreRelation, partition, child, overwrite, ifNotExists)
- // Inserting into partitioned table is not supported in Orc data source (yet).
- if !r.hiveQlTable.isPartitioned && shouldConvertMetastoreOrc(r) =>
- InsertIntoTable(convertToOrcRelation(r), partition, child, overwrite, ifNotExists)
-
// Read path
case relation: MetastoreRelation if shouldConvertMetastoreOrc(relation) =>
val orcRelation = convertToOrcRelation(relation)
@@ -489,30 +477,3 @@ private[hive] object MetaStorePartitionedTableFileCatalog {
}
}
}
-
-/**
- * A logical plan representing insertion into Hive table.
- * This plan ignores nullability of ArrayType, MapType, StructType unlike InsertIntoTable
- * because Hive table doesn't have nullability for ARRAY, MAP, STRUCT types.
- */
-private[hive] case class InsertIntoHiveTable(
- table: MetastoreRelation,
- partition: Map[String, Option[String]],
- child: LogicalPlan,
- overwrite: Boolean,
- ifNotExists: Boolean)
- extends LogicalPlan with Command {
-
- override def children: Seq[LogicalPlan] = child :: Nil
- override def output: Seq[Attribute] = Seq.empty
-
- val numDynamicPartitions = partition.values.count(_.isEmpty)
-
- // This is the expected schema of the table prepared to be inserted into,
- // including dynamic partition columns.
- val tableOutput = table.attributes ++ table.partitionKeys.takeRight(numDynamicPartitions)
-
- override lazy val resolved: Boolean = childrenResolved && child.output.zip(tableOutput).forall {
- case (childAttr, tableAttr) => childAttr.dataType.sameType(tableAttr.dataType)
- }
-}
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveStrategies.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveStrategies.scala
index 71b180e55b..17956ded17 100644
--- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveStrategies.scala
+++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveStrategies.scala
@@ -44,12 +44,7 @@ private[hive] trait HiveStrategies {
def apply(plan: LogicalPlan): Seq[SparkPlan] = plan match {
case logical.InsertIntoTable(
table: MetastoreRelation, partition, child, overwrite, ifNotExists) =>
- execution.InsertIntoHiveTable(
- table, partition, planLater(child), overwrite, ifNotExists) :: Nil
- case hive.InsertIntoHiveTable(
- table: MetastoreRelation, partition, child, overwrite, ifNotExists) =>
- execution.InsertIntoHiveTable(
- table, partition, planLater(child), overwrite, ifNotExists) :: Nil
+ InsertIntoHiveTable(table, partition, planLater(child), overwrite, ifNotExists) :: Nil
case _ => Nil
}
}
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala
index f5d2f02d51..80e75aa898 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala
@@ -31,7 +31,6 @@ import org.apache.spark.sql.catalyst.planning.PhysicalOperation
import org.apache.spark.sql.catalyst.plans.logical._
import org.apache.spark.sql.catalyst.util._
import org.apache.spark.sql.execution.command._
-import org.apache.spark.sql.hive.{InsertIntoHiveTable => LogicalInsertIntoHiveTable}
import org.apache.spark.sql.hive.test.{TestHive, TestHiveQueryExecution}
/**
@@ -349,7 +348,6 @@ abstract class HiveComparisonTest
val containsCommands = originalQuery.analyzed.collectFirst {
case _: Command => ()
case _: InsertIntoTable => ()
- case _: LogicalInsertIntoHiveTable => ()
}.nonEmpty
if (containsCommands) {