Skip to content

Commit a73ff6f

Browse files
committed
add storage flag for cached local relations
1 parent fac11c4 commit a73ff6f

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5139,6 +5139,15 @@ object SQLConf {
51395139
.booleanConf
51405140
.createWithDefault(false)
51415141

5142+
val ARTIFACT_MANAGER_CACHE_STORAGE_LEVEL =
5143+
buildConf("spark.sql.artifact.cacheStorageLevel")
5144+
.internal()
5145+
.doc("Storage level for cached blocks in artifact manager. Valid values are any " +
5146+
"StorageLevel name (e.g., MEMORY_AND_DISK_SER, DISK_ONLY, MEMORY_ONLY, etc.).")
5147+
.version("4.2.0")
5148+
.stringConf
5149+
.createWithDefault("MEMORY_AND_DISK_SER")
5150+
51425151
val FAST_HASH_AGGREGATE_MAX_ROWS_CAPACITY_BIT =
51435152
buildConf("spark.sql.codegen.aggregate.fastHashMap.capacityBit")
51445153
.internal()

sql/core/src/main/scala/org/apache/spark/sql/artifact/ArtifactManager.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,17 @@ class ArtifactManager(session: SparkSession) extends AutoCloseable with Logging
194194
// (e.g., after clone), we should replace it.
195195
val existingBlock = hashToCachedIdMap.get(hash)
196196
if (existingBlock == null || existingBlock.id != blockId) {
197+
val storageLevelStr = session.conf.get(
198+
SQLConf.ARTIFACT_MANAGER_CACHE_STORAGE_LEVEL)
199+
val storageLevel = try {
200+
StorageLevel.fromString(storageLevelStr)
201+
} catch {
202+
case e: IllegalArgumentException =>
203+
logWarning(
204+
log"Invalid storage level '${MDC(LogKeys.STORAGE_LEVEL, storageLevelStr)}' " +
205+
log"for artifact cache, falling back to MEMORY_AND_DISK_SER", e)
206+
StorageLevel.MEMORY_AND_DISK_SER
207+
}
197208
val updater = blockManager.TempFileBasedBlockStoreUpdater(
198209
blockId = blockId,
199210
level = StorageLevel.MEMORY_AND_DISK_SER,

0 commit comments

Comments
 (0)