File tree 2 files changed +21
-11
lines changed
main/scala/org/apache/spark/sql/delta
test/scala/org/apache/spark/sql/delta
2 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -641,7 +641,7 @@ object DeltaLog extends DeltaLogging {
641
641
/**
642
642
* Helper to create delta log caches
643
643
*/
644
- private [delta] def createCacheBuilder (conf : SQLConf ): CacheBuilder [AnyRef , AnyRef ] = {
644
+ private def createCacheBuilder (conf : SQLConf ): CacheBuilder [AnyRef , AnyRef ] = {
645
645
val cacheRetention = conf.getConf(DeltaSQLConf .DELTA_LOG_CACHE_RETENTION_MINUTES )
646
646
val cacheSize = conf
647
647
.getConf(DeltaSQLConf .DELTA_LOG_CACHE_SIZE )
@@ -808,8 +808,8 @@ object DeltaLog extends DeltaLogging {
808
808
// - Different `authority` (e.g., different user tokens in the path)
809
809
// - Different mount point.
810
810
try {
811
- getOrCreateCache(spark.sessionState.conf).get(
812
- path -> fileSystemOptions, () => {
811
+ getOrCreateCache(spark.sessionState.conf)
812
+ .get( path -> fileSystemOptions, () => {
813
813
createDeltaLog()
814
814
}
815
815
)
@@ -864,9 +864,7 @@ object DeltaLog extends DeltaLogging {
864
864
}
865
865
866
866
def clearCache (): Unit = {
867
- deltaLogCache.foreach { cache =>
868
- cache.invalidateAll()
869
- }
867
+ deltaLogCache.foreach(_.invalidateAll())
870
868
}
871
869
872
870
/** Unset the caches. Exposing for testing */
Original file line number Diff line number Diff line change @@ -655,10 +655,22 @@ class DeltaLogSuite extends QueryTest
655
655
assert(DeltaLog .cacheSize === expected)
656
656
}
657
657
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
+ }
663
675
}
664
676
}
You can’t perform that action at this time.
0 commit comments