Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 12d401f

Browse files
committedFeb 15, 2024·
update
1 parent eccf670 commit 12d401f

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed
 

‎spark/src/main/scala/org/apache/spark/sql/delta/DeltaLog.scala

+4-6
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ object DeltaLog extends DeltaLogging {
641641
/**
642642
* Helper to create delta log caches
643643
*/
644-
private[delta] def createCacheBuilder(conf: SQLConf): CacheBuilder[AnyRef, AnyRef] = {
644+
private def createCacheBuilder(conf: SQLConf): CacheBuilder[AnyRef, AnyRef] = {
645645
val cacheRetention = conf.getConf(DeltaSQLConf.DELTA_LOG_CACHE_RETENTION_MINUTES)
646646
val cacheSize = conf
647647
.getConf(DeltaSQLConf.DELTA_LOG_CACHE_SIZE)
@@ -808,8 +808,8 @@ object DeltaLog extends DeltaLogging {
808808
// - Different `authority` (e.g., different user tokens in the path)
809809
// - Different mount point.
810810
try {
811-
getOrCreateCache(spark.sessionState.conf).get(
812-
path -> fileSystemOptions, () => {
811+
getOrCreateCache(spark.sessionState.conf)
812+
.get(path -> fileSystemOptions, () => {
813813
createDeltaLog()
814814
}
815815
)
@@ -864,9 +864,7 @@ object DeltaLog extends DeltaLogging {
864864
}
865865

866866
def clearCache(): Unit = {
867-
deltaLogCache.foreach { cache =>
868-
cache.invalidateAll()
869-
}
867+
deltaLogCache.foreach(_.invalidateAll())
870868
}
871869

872870
/** Unset the caches. Exposing for testing */

‎spark/src/test/scala/org/apache/spark/sql/delta/DeltaLogSuite.scala

+17-5
Original file line numberDiff line numberDiff line change
@@ -655,10 +655,22 @@ class DeltaLogSuite extends QueryTest
655655
assert(DeltaLog.cacheSize === expected)
656656
}
657657
DeltaLog.unsetCache()
658-
spark.sessionState.conf.setConf(DeltaSQLConf.DELTA_LOG_CACHE_SIZE, 2L)
659-
assertCacheSize(2)
660-
DeltaLog.unsetCache()
661-
System.getProperties.setProperty("delta.log.cacheSize", "3")
662-
assertCacheSize(3)
658+
withSQLConf(DeltaSQLConf.DELTA_LOG_CACHE_SIZE.key -> "2") {
659+
assertCacheSize(2)
660+
DeltaLog.unsetCache()
661+
// the larger of SQLConf and env var is adopted
662+
try {
663+
System.getProperties.setProperty("delta.log.cacheSize", "3")
664+
assertCacheSize(3)
665+
} finally {
666+
System.getProperties.remove("delta.log.cacheSize")
667+
}
668+
}
669+
670+
// assert timeconf returns correct value
671+
withSQLConf(DeltaSQLConf.DELTA_LOG_CACHE_RETENTION_MINUTES.key -> "100") {
672+
assert(spark.sessionState.conf.getConf(
673+
DeltaSQLConf.DELTA_LOG_CACHE_RETENTION_MINUTES) === 100)
674+
}
663675
}
664676
}

0 commit comments

Comments
 (0)