cloud-fan commented on a change in pull request #25600: [SPARK-11150][SQL]
Dynamic Partition Pruning
URL: https://github.com/apache/spark/pull/25600#discussion_r318432555
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/DataSourceScanExec.scala
##########
@@ -184,20 +184,51 @@ case class FileSourceScanExec(
metrics.filter(e => driverMetrics.contains(e._1)).values.toSeq)
}
+ private def isDynamicPruningFilter(e: Expression): Boolean =
+ e.find(_.isInstanceOf[PlanExpression[_]]).isDefined
+
@transient private lazy val selectedPartitions: Array[PartitionDirectory] = {
val optimizerMetadataTimeNs =
relation.location.metadataOpsTimeNs.getOrElse(0L)
val startTime = System.nanoTime()
- val ret = relation.location.listFiles(partitionFilters, dataFilters)
+ val ret =
+ relation.location.listFiles(
+ partitionFilters.filterNot(isDynamicPruningFilter), dataFilters)
if (relation.partitionSchemaOption.isDefined) {
driverMetrics("numPartitions") = ret.length
}
- driverMetrics("numFiles") = ret.map(_.files.size.toLong).sum
+ setFilesNumAndSizeMetric(ret, true)
val timeTakenMs = NANOSECONDS.toMillis(
(System.nanoTime() - startTime) + optimizerMetadataTimeNs)
driverMetrics("metadataTime") = timeTakenMs
ret
}.toArray
+ // We can only determine the actual partitions at runtime when a dynamic
partition filter is
+ // present. This is because such a filter relies on information that is only
available at run
+ // time (for instance the keys used in the other side of a join).
+ @transient private lazy val dynamicallySelectedPartitions:
Array[PartitionDirectory] = {
Review comment:
We only access `selectedPartitions` before runtime when
`LEGACY_BUCKETED_TABLE_SCAN_OUTPUT_ORDERING` is true. Can we add a todo that,
once we remove `LEGACY_BUCKETED_TABLE_SCAN_OUTPUT_ORDERING`, we can merge
`selectedPartitions` and `dynamicallySelectedPartitions`?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]