sunchao commented on a change in pull request #30815:
URL: https://github.com/apache/spark/pull/30815#discussion_r545298884
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala
##########
@@ -88,12 +88,34 @@ class CacheManager extends Logging with
AdaptiveSparkPlanHelper {
query: Dataset[_],
tableName: Option[String] = None,
storageLevel: StorageLevel = MEMORY_AND_DISK): Unit = {
- val planToCache = query.logicalPlan
+ cacheQuery(query.sparkSession, query.logicalPlan, tableName, storageLevel)
+ }
+
+ /**
+ * Caches the data produced by the given [[LogicalPlan]].
+ * Unlike `RDD.cache()`, the default storage level is set to be
`MEMORY_AND_DISK` because
+ * recomputing the in-memory columnar representation of the underlying table
is expensive.
+ */
+ def cacheQuery(
Review comment:
+1 on this! I think we may replace one more usage in
`DataSourceV2Strategy.invalidateCache` as well.
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala
##########
@@ -88,12 +88,34 @@ class CacheManager extends Logging with
AdaptiveSparkPlanHelper {
query: Dataset[_],
tableName: Option[String] = None,
storageLevel: StorageLevel = MEMORY_AND_DISK): Unit = {
- val planToCache = query.logicalPlan
+ cacheQuery(query.sparkSession, query.logicalPlan, tableName, storageLevel)
+ }
+
+ /**
+ * Caches the data produced by the given [[LogicalPlan]].
+ * Unlike `RDD.cache()`, the default storage level is set to be
`MEMORY_AND_DISK` because
+ * recomputing the in-memory columnar representation of the underlying table
is expensive.
+ */
+ def cacheQuery(
+ spark: SparkSession,
+ planToCache: LogicalPlan,
+ tableName: Option[String]): Unit = {
+ cacheQuery(spark, planToCache, tableName, MEMORY_AND_DISK)
+ }
+
+ /**
+ * Caches the data produced by the given [[LogicalPlan]].
+ */
+ def cacheQuery(
+ spark: SparkSession,
+ planToCache: LogicalPlan,
+ tableName: Option[String],
+ storageLevel: StorageLevel): Unit = {
Review comment:
perhaps we can just keep a single method with default value of
`tableName` being `None` and `storageLevel` being `MEMORY_AND_DISK`?
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]