Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Disable predicate pushdown when hive metastore version is older than
0.13
  • Loading branch information
Cheolsoo Park committed Jun 29, 2015
commit ead139a4948d4aa5d10905cdb6fc7adbe3b12465
12 changes: 11 additions & 1 deletion sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveShim.scala
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,17 @@ private[hive] object HiveShim {

def toMetastoreFilter(
predicates: Seq[Expression],
partitionKeys: List[FieldSchema]): Option[String] = {
partitionKeys: List[FieldSchema],
hiveMetastoreVersion: String): Option[String] = {

// Binary comparison operators such as >, <, >=, and <= started being supported by
// getPartitionsByFilter() in 0.13. So if Hive matastore version is older than 0.13,
// no predicate is pushed down. See HIVE-4888.
val versionPattern = "([\\d]+\\.[\\d]+).*".r
hiveMetastoreVersion match {
case versionPattern(version) => if (version.toDouble < 0.13) return None
case _ => // continue
}

val varcharKeys = partitionKeys
.filter(col => col.getType.startsWith(serdeConstants.VARCHAR_TYPE_NAME))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ case class HiveTableScan(
val attributes = requestedAttributes.map(relation.attributeMap)

private[this] val metastoreFilter =
HiveShim.toMetastoreFilter(partitionPruningPred, relation.hiveQlTable.getPartitionKeys)
HiveShim.toMetastoreFilter(
partitionPruningPred,
relation.hiveQlTable.getPartitionKeys,
context.hiveMetastoreVersion)

// Bind all partition key attribute references in the partition pruning predicate for later
// evaluation.
Expand Down