viirya commented on code in PR #39377:
URL: https://github.com/apache/spark/pull/39377#discussion_r1063170911
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/dynamicpruning/PartitionPruning.scala:
##########
@@ -183,28 +184,20 @@ object PartitionPruning extends Rule[LogicalPlan] with
PredicateHelper with Join
})
val scanOverhead = notCached.map(_.stats.sizeInBytes).sum.toFloat
val cachedOverhead = cached.map {
- case m: InMemoryRelation if m.cacheBuilder.storageLevel.useDisk &&
- !m.cacheBuilder.storageLevel.useMemory =>
- m.stats.sizeInBytes.toFloat
- case m: InMemoryRelation if m.cacheBuilder.storageLevel.useDisk =>
- m.stats.sizeInBytes.toFloat * 0.2
- case m: InMemoryRelation if m.cacheBuilder.storageLevel.useMemory =>
- 0.0
+ case m: InMemoryRelation if m.isMaterialized =>
+ if (m.cacheBuilder.storageLevel.useDisk &&
!m.cacheBuilder.storageLevel.useMemory) {
+ m.stats.sizeInBytes.toFloat
+ } else if (m.cacheBuilder.storageLevel.useDisk) {
+ m.stats.sizeInBytes.toFloat * 0.2
+ } else {
+ // use memory only
+ 0.0
+ }
+ case m => m.stats.sizeInBytes.toFloat
Review Comment:
Hmm, this looks okay, although I guess that the cost of materializing maybe
be still larger for `useDisk` (writing to disk?) than `useMemory` too?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]