aboutsummaryrefslogtreecommitdiff
path: root/sql/hive
diff options
context:
space:
mode:
authorMichael Armbrust <michael@databricks.com>2015-08-12 17:07:29 -0700
committerMichael Armbrust <michael@databricks.com>2015-08-12 17:07:29 -0700
commit660e6dcff8125b83cc73dbe00c90cbe58744bc66 (patch)
treeeb2cdf02de009c87b73691641602845c9469515f /sql/hive
parentfc1c7fd66e64ccea53b31cd2fbb98bc6d307329c (diff)
downloadspark-660e6dcff8125b83cc73dbe00c90cbe58744bc66.tar.gz
spark-660e6dcff8125b83cc73dbe00c90cbe58744bc66.tar.bz2
spark-660e6dcff8125b83cc73dbe00c90cbe58744bc66.zip
[SPARK-9449] [SQL] Include MetastoreRelation's inputFiles
Author: Michael Armbrust <michael@databricks.com> Closes #8119 from marmbrus/metastoreInputFiles.
Diffstat (limited to 'sql/hive')
-rw-r--r--sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala16
1 files changed, 14 insertions, 2 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 ac9aaed19d..5e5497837a 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
@@ -38,7 +38,7 @@ import org.apache.spark.sql.catalyst.plans.logical
import org.apache.spark.sql.catalyst.plans.logical._
import org.apache.spark.sql.catalyst.rules._
import org.apache.spark.sql.catalyst.{InternalRow, SqlParser, TableIdentifier}
-import org.apache.spark.sql.execution.datasources
+import org.apache.spark.sql.execution.{FileRelation, datasources}
import org.apache.spark.sql.execution.datasources.{CreateTableUsingAsSelect, LogicalRelation, Partition => ParquetPartition, PartitionSpec, ResolvedDataSource}
import org.apache.spark.sql.hive.client._
import org.apache.spark.sql.execution.datasources.parquet.ParquetRelation
@@ -739,7 +739,7 @@ private[hive] case class MetastoreRelation
(databaseName: String, tableName: String, alias: Option[String])
(val table: HiveTable)
(@transient sqlContext: SQLContext)
- extends LeafNode with MultiInstanceRelation {
+ extends LeafNode with MultiInstanceRelation with FileRelation {
override def equals(other: Any): Boolean = other match {
case relation: MetastoreRelation =>
@@ -888,6 +888,18 @@ private[hive] case class MetastoreRelation
/** An attribute map for determining the ordinal for non-partition columns. */
val columnOrdinals = AttributeMap(attributes.zipWithIndex)
+ override def inputFiles: Array[String] = {
+ val partLocations = table.getPartitions(Nil).map(_.storage.location).toArray
+ if (partLocations.nonEmpty) {
+ partLocations
+ } else {
+ Array(
+ table.location.getOrElse(
+ sys.error(s"Could not get the location of ${table.qualifiedName}.")))
+ }
+ }
+
+
override def newInstance(): MetastoreRelation = {
MetastoreRelation(databaseName, tableName, alias)(table)(sqlContext)
}