-
Notifications
You must be signed in to change notification settings - Fork 29.1k
[SPARK-30525][SQL]HiveTableScanExec do not need to prune partitions again after pushing down to SessionCatalog for partition pruning #27232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
837dc48
Do not need to prune partitions again after SessionCatalog.listPartit…
fuwhu 6cfa4ab
Refine code.
fuwhu f86671d
refine code.
fuwhu d96f19b
fix unit test failure.
fuwhu 5bc37c3
refine code
fuwhu 057a594
refine code
fuwhu f0ad037
refine code
fuwhu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,7 +146,7 @@ case class HiveTableScanExec( | |
| * @param partitions All partitions of the relation. | ||
| * @return Partitions that are involved in the query plan. | ||
| */ | ||
| private[hive] def prunePartitions(partitions: Seq[HivePartition]) = { | ||
| private[hive] def prunePartitions(partitions: Seq[HivePartition]): Seq[HivePartition] = { | ||
| boundPruningPred match { | ||
| case None => partitions | ||
| case Some(shouldKeep) => partitions.filter { part => | ||
|
|
@@ -162,18 +162,36 @@ case class HiveTableScanExec( | |
| } | ||
| } | ||
|
|
||
| @transient lazy val prunedPartitions: Seq[HivePartition] = { | ||
| if (relation.prunedPartitions.nonEmpty) { | ||
| val hivePartitions = | ||
| relation.prunedPartitions.get.map(HiveClientImpl.toHivePartition(_, hiveQlTable)) | ||
| if (partitionPruningPred.forall(!ExecSubqueryExpression.hasSubquery(_))) { | ||
| hivePartitions | ||
| } else { | ||
| prunePartitions(hivePartitions) | ||
| } | ||
| } else { | ||
| if (sparkSession.sessionState.conf.metastorePartitionPruning && | ||
| partitionPruningPred.nonEmpty) { | ||
| rawPartitions | ||
| } else { | ||
| prunePartitions(rawPartitions) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // exposed for tests | ||
| @transient lazy val rawPartitions = { | ||
| @transient lazy val rawPartitions: Seq[HivePartition] = { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when we call
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, removed. |
||
| val prunedPartitions = | ||
| if (sparkSession.sessionState.conf.metastorePartitionPruning && | ||
| partitionPruningPred.nonEmpty) { | ||
| partitionPruningPred.nonEmpty) { | ||
| // Retrieve the original attributes based on expression ID so that capitalization matches. | ||
| val normalizedFilters = partitionPruningPred.map(_.transform { | ||
| case a: AttributeReference => originalAttributes(a) | ||
| }) | ||
| relation.prunedPartitions.getOrElse( | ||
| sparkSession.sessionState.catalog | ||
| .listPartitionsByFilter(relation.tableMeta.identifier, normalizedFilters)) | ||
| sparkSession.sessionState.catalog | ||
| .listPartitionsByFilter(relation.tableMeta.identifier, normalizedFilters) | ||
| } else { | ||
| sparkSession.sessionState.catalog.listPartitions(relation.tableMeta.identifier) | ||
| } | ||
|
|
@@ -189,7 +207,7 @@ case class HiveTableScanExec( | |
| } | ||
| } else { | ||
| Utils.withDummyCallSite(sqlContext.sparkContext) { | ||
| hadoopReader.makeRDDForPartitionedTable(prunePartitions(rawPartitions)) | ||
| hadoopReader.makeRDDForPartitionedTable(prunedPartitions) | ||
| } | ||
| } | ||
| val numOutputRows = longMetric("numOutputRows") | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.