You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/12/17 03:28:33 UTC

[GitHub] [spark] imback82 opened a new pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

imback82 opened a new pull request #30815:
URL: https://github.com/apache/spark/pull/30815


   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   This PR proposes to update `CACHE TABLE` to use a `LogicalPlan` when caching a query to avoid creating a `DataFrame` as suggested here: https://github.com/apache/spark/pull/30743#discussion_r543123190
   
   For reference, `UNCACHE TABLE` also uses `LogicalPlan`: https://github.com/apache/spark/blob/0c129001201ccb63ae96f576b6f354da84024fb3/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/CacheTableExec.scala#L91-L98
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   To avoid creating an unnecessary dataframe and make it consistent with `uncacheQuery` used in `UNCACHE TABLE`.
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   No, just internal changes.
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   Existing tests since this is an internal refactoring change.


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747350689






----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747193234


   **[Test build #132921 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132921/testReport)** for PR 30815 at commit [`d9dcfb3`](https://github.com/apache/spark/commit/d9dcfb38e9a0701832bf1d653295228a7162b084).


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747534917


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/37561/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747575824


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/37561/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747350689


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/132934/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] sunchao commented on a change in pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
sunchao commented on a change in pull request #30815:
URL: https://github.com/apache/spark/pull/30815#discussion_r545302857



##########
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:
       Ah got it. Thanks.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan closed pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
cloud-fan closed pull request #30815:
URL: https://github.com/apache/spark/pull/30815


   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747255085


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/37537/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747733943


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/37567/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747860684


   thanks, merging to master!


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747590478


   cc @sunchao 


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747773199


   **[Test build #132959 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132959/testReport)** for PR 30815 at commit [`52de954`](https://github.com/apache/spark/commit/52de9548ebf713a83f649cb5dbb86c1b9e7a1750).
    * This patch **fails from timeout after a configured wait of `500m`**.
    * This patch merges cleanly.
    * This patch adds no public classes.


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747785873


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/132959/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747312211


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/132921/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] imback82 commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
imback82 commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747207300


   cc @cloud-fan, thanks!


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA removed a comment on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747501973


   **[Test build #132959 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132959/testReport)** for PR 30815 at commit [`52de954`](https://github.com/apache/spark/commit/52de9548ebf713a83f649cb5dbb86c1b9e7a1750).


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747268149


   Kubernetes integration test status success
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/37537/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA removed a comment on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747233417


   **[Test build #132934 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132934/testReport)** for PR 30815 at commit [`52de954`](https://github.com/apache/spark/commit/52de9548ebf713a83f649cb5dbb86c1b9e7a1750).


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747733943


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/37567/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747721693


   Kubernetes integration test status failure
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/37567/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA removed a comment on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747677836


   **[Test build #132964 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132964/testReport)** for PR 30815 at commit [`bc80b6d`](https://github.com/apache/spark/commit/bc80b6d30307b7876a1b4e4e8d383bd387d89b0a).


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747283180


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/37537/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747703818


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/37567/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] imback82 commented on a change in pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
imback82 commented on a change in pull request #30815:
URL: https://github.com/apache/spark/pull/30815#discussion_r544818506



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala
##########
@@ -88,12 +88,24 @@ class CacheManager extends Logging with AdaptiveSparkPlanHelper {
       query: Dataset[_],
       tableName: Option[String] = None,
       storageLevel: StorageLevel = MEMORY_AND_DISK): Unit = {
-    val planToCache = query.logicalPlan
+    cacheQueryWithLogicalPlan(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 cacheQueryWithLogicalPlan(

Review comment:
       Unfortunately, we cannot because Scala doesn't allow overloading methods with default arguments.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] imback82 commented on a change in pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
imback82 commented on a change in pull request #30815:
URL: https://github.com/apache/spark/pull/30815#discussion_r545359286



##########
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:
       thanks, updated.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747677836


   **[Test build #132964 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132964/testReport)** for PR 30815 at commit [`bc80b6d`](https://github.com/apache/spark/commit/bc80b6d30307b7876a1b4e4e8d383bd387d89b0a).


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747309494


   **[Test build #132921 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132921/testReport)** for PR 30815 at commit [`d9dcfb3`](https://github.com/apache/spark/commit/d9dcfb38e9a0701832bf1d653295228a7162b084).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds no public classes.


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747501973


   **[Test build #132959 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132959/testReport)** for PR 30815 at commit [`52de954`](https://github.com/apache/spark/commit/52de9548ebf713a83f649cb5dbb86c1b9e7a1750).


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747804927


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/132964/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747804927


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/132964/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747349725


   **[Test build #132934 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132934/testReport)** for PR 30815 at commit [`52de954`](https://github.com/apache/spark/commit/52de9548ebf713a83f649cb5dbb86c1b9e7a1750).
    * This patch **fails PySpark unit tests**.
    * This patch merges cleanly.
    * This patch adds no public classes.


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on a change in pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #30815:
URL: https://github.com/apache/spark/pull/30815#discussion_r545302003



##########
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:
       The scala compiler will complain if we do that. See https://github.com/apache/spark/pull/30815#discussion_r544815956




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747283180


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/37537/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747194128


   Kubernetes integration test status failure
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/37524/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA removed a comment on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747193234


   **[Test build #132921 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132921/testReport)** for PR 30815 at commit [`d9dcfb3`](https://github.com/apache/spark/commit/d9dcfb38e9a0701832bf1d653295228a7162b084).


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] sunchao commented on a change in pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] imback82 commented on a change in pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
imback82 commented on a change in pull request #30815:
URL: https://github.com/apache/spark/pull/30815#discussion_r544822268



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala
##########
@@ -88,12 +88,24 @@ class CacheManager extends Logging with AdaptiveSparkPlanHelper {
       query: Dataset[_],
       tableName: Option[String] = None,
       storageLevel: StorageLevel = MEMORY_AND_DISK): Unit = {
-    val planToCache = query.logicalPlan
+    cacheQueryWithLogicalPlan(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 cacheQueryWithLogicalPlan(

Review comment:
       Ah, I think we can do the folllowing:
   ```scala
     def cacheQuery(
       spark: SparkSession,
       planToCache: LogicalPlan,
       tableName: Option[String]): Unit = {
       cacheQuery(spark, planToCache, tableName, MEMORY_AND_DISK)
     }
   
     def cacheQuery(
         spark: SparkSession,
         planToCache: LogicalPlan,
         tableName: Option[String],
         storageLevel: StorageLevel)
   ```




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747796225


   **[Test build #132964 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132964/testReport)** for PR 30815 at commit [`bc80b6d`](https://github.com/apache/spark/commit/bc80b6d30307b7876a1b4e4e8d383bd387d89b0a).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds no public classes.


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on a change in pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #30815:
URL: https://github.com/apache/spark/pull/30815#discussion_r544822162



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala
##########
@@ -88,12 +88,24 @@ class CacheManager extends Logging with AdaptiveSparkPlanHelper {
       query: Dataset[_],
       tableName: Option[String] = None,
       storageLevel: StorageLevel = MEMORY_AND_DISK): Unit = {
-    val planToCache = query.logicalPlan
+    cacheQueryWithLogicalPlan(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 cacheQueryWithLogicalPlan(

Review comment:
       Ah, got it. Then how about `cacheLogicalPlan` to be simpler?




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on a change in pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #30815:
URL: https://github.com/apache/spark/pull/30815#discussion_r544815956



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala
##########
@@ -88,12 +88,24 @@ class CacheManager extends Logging with AdaptiveSparkPlanHelper {
       query: Dataset[_],
       tableName: Option[String] = None,
       storageLevel: StorageLevel = MEMORY_AND_DISK): Unit = {
-    val planToCache = query.logicalPlan
+    cacheQueryWithLogicalPlan(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 cacheQueryWithLogicalPlan(

Review comment:
       shall we just call it `cacheQuery` to be consistent with `uncacheQuery`?




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on a change in pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #30815:
URL: https://github.com/apache/spark/pull/30815#discussion_r544822490



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala
##########
@@ -88,12 +88,24 @@ class CacheManager extends Logging with AdaptiveSparkPlanHelper {
       query: Dataset[_],
       tableName: Option[String] = None,
       storageLevel: StorageLevel = MEMORY_AND_DISK): Unit = {
-    val planToCache = query.logicalPlan
+    cacheQueryWithLogicalPlan(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 cacheQueryWithLogicalPlan(
+      spark: SparkSession,
+      planToCache: LogicalPlan,
+      tableName: Option[String] = None,

Review comment:
       does this method need default parameter values?




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747785873


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/132959/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747194137


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/37524/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747233417


   **[Test build #132934 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132934/testReport)** for PR 30815 at commit [`52de954`](https://github.com/apache/spark/commit/52de9548ebf713a83f649cb5dbb86c1b9e7a1750).


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747484985


   retest this please


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747554939


   Kubernetes integration test status success
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/37561/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747192958


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/37524/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747194137


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/37524/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30815:
URL: https://github.com/apache/spark/pull/30815#issuecomment-747312211


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/132921/
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] imback82 commented on a change in pull request #30815: [SPARK-33817][SQL] CACHE TABLE uses a logical plan when caching a query to avoid creating a dataframe

Posted by GitBox <gi...@apache.org>.
imback82 commented on a change in pull request #30815:
URL: https://github.com/apache/spark/pull/30815#discussion_r544823257



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala
##########
@@ -88,12 +88,24 @@ class CacheManager extends Logging with AdaptiveSparkPlanHelper {
       query: Dataset[_],
       tableName: Option[String] = None,
       storageLevel: StorageLevel = MEMORY_AND_DISK): Unit = {
-    val planToCache = query.logicalPlan
+    cacheQueryWithLogicalPlan(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 cacheQueryWithLogicalPlan(
+      spark: SparkSession,
+      planToCache: LogicalPlan,
+      tableName: Option[String] = None,

Review comment:
       I think https://github.com/apache/spark/pull/30815/files#r544822268 should work. Let me update this PR. Thanks!




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org