maryannxue commented on a change in pull request #25600: [SPARK-11150][SQL]
Dynamic Partition Pruning
URL: https://github.com/apache/spark/pull/25600#discussion_r318607818
##########
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:
I'm +1 on that. But maybe we should still get the statically filtered
partitions as a local variable and set the static metrics.
----------------------------------------------------------------
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]