Skip to content
Snippets Groups Projects
Commit ce89ff47 authored by Michael Armbrust's avatar Michael Armbrust Committed by Yin Huai
Browse files

[SPARK-9386] [SQL] Feature flag for metastore partition pruning

Since we have been seeing a lot of failures related to this new feature, lets put it behind a flag and turn it off by default.

Author: Michael Armbrust <michael@databricks.com>

Closes #7703 from marmbrus/optionalMetastorePruning and squashes the following commits:

6ad128c [Michael Armbrust] style
8447835 [Michael Armbrust] [SPARK-9386][SQL] Feature flag for metastore partition pruning
fd37b87 [Michael Armbrust] add config flag
parent 8ddfa52c
No related branches found
No related tags found
No related merge requests found
...@@ -301,6 +301,11 @@ private[spark] object SQLConf { ...@@ -301,6 +301,11 @@ private[spark] object SQLConf {
defaultValue = Some(true), defaultValue = Some(true),
doc = "<TODO>") doc = "<TODO>")
val HIVE_METASTORE_PARTITION_PRUNING = booleanConf("spark.sql.hive.metastorePartitionPruning",
defaultValue = Some(false),
doc = "When true, some predicates will be pushed down into the Hive metastore so that " +
"unmatching partitions can be eliminated earlier.")
val COLUMN_NAME_OF_CORRUPT_RECORD = stringConf("spark.sql.columnNameOfCorruptRecord", val COLUMN_NAME_OF_CORRUPT_RECORD = stringConf("spark.sql.columnNameOfCorruptRecord",
defaultValue = Some("_corrupt_record"), defaultValue = Some("_corrupt_record"),
doc = "<TODO>") doc = "<TODO>")
...@@ -456,6 +461,8 @@ private[sql] class SQLConf extends Serializable with CatalystConf { ...@@ -456,6 +461,8 @@ private[sql] class SQLConf extends Serializable with CatalystConf {
private[spark] def verifyPartitionPath: Boolean = getConf(HIVE_VERIFY_PARTITION_PATH) private[spark] def verifyPartitionPath: Boolean = getConf(HIVE_VERIFY_PARTITION_PATH)
private[spark] def metastorePartitionPruning: Boolean = getConf(HIVE_METASTORE_PARTITION_PRUNING)
private[spark] def externalSortEnabled: Boolean = getConf(EXTERNAL_SORT) private[spark] def externalSortEnabled: Boolean = getConf(EXTERNAL_SORT)
private[spark] def sortMergeJoinEnabled: Boolean = getConf(SORTMERGE_JOIN) private[spark] def sortMergeJoinEnabled: Boolean = getConf(SORTMERGE_JOIN)
......
...@@ -678,8 +678,18 @@ private[hive] case class MetastoreRelation ...@@ -678,8 +678,18 @@ private[hive] case class MetastoreRelation
} }
) )
// When metastore partition pruning is turned off, we cache the list of all partitions to
// mimic the behavior of Spark < 1.5
lazy val allPartitions = table.getAllPartitions
def getHiveQlPartitions(predicates: Seq[Expression] = Nil): Seq[Partition] = { def getHiveQlPartitions(predicates: Seq[Expression] = Nil): Seq[Partition] = {
table.getPartitions(predicates).map { p => val rawPartitions = if (sqlContext.conf.metastorePartitionPruning) {
table.getPartitions(predicates)
} else {
allPartitions
}
rawPartitions.map { p =>
val tPartition = new org.apache.hadoop.hive.metastore.api.Partition val tPartition = new org.apache.hadoop.hive.metastore.api.Partition
tPartition.setDbName(databaseName) tPartition.setDbName(databaseName)
tPartition.setTableName(tableName) tPartition.setTableName(tableName)
......
...@@ -72,12 +72,10 @@ private[hive] case class HiveTable( ...@@ -72,12 +72,10 @@ private[hive] case class HiveTable(
def isPartitioned: Boolean = partitionColumns.nonEmpty def isPartitioned: Boolean = partitionColumns.nonEmpty
def getPartitions(predicates: Seq[Expression]): Seq[HivePartition] = { def getAllPartitions: Seq[HivePartition] = client.getAllPartitions(this)
predicates match {
case Nil => client.getAllPartitions(this) def getPartitions(predicates: Seq[Expression]): Seq[HivePartition] =
case _ => client.getPartitionsByFilter(this, predicates) client.getPartitionsByFilter(this, predicates)
}
}
// Hive does not support backticks when passing names to the client. // Hive does not support backticks when passing names to the client.
def qualifiedName: String = s"$database.$name" def qualifiedName: String = s"$database.$name"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment