You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by ueshin <gi...@git.apache.org> on 2016/06/13 07:16:20 UTC

[GitHub] spark pull request #13638: [SPARK-15915][SQL] CacheManager should use canoni...

GitHub user ueshin opened a pull request:

    https://github.com/apache/spark/pull/13638

    [SPARK-15915][SQL] CacheManager should use canonicalized plan for planToCache.

    ## What changes were proposed in this pull request?
    
    `DataFrame` with plan overriding `sameResult` but not using canonicalized plan to compare can't cacheTable.
    
    The example is like:
    
    ```
        val localRelation = Seq(1, 2, 3).toDF()
        localRelation.createOrReplaceTempView("localRelation")
    
        spark.catalog.cacheTable("localRelation")
        assert(
          localRelation.queryExecution.withCachedData.collect {
            case i: InMemoryRelation => i
          }.size == 1)
    ```
    
    and this will fail as:
    
    ```
    ArrayBuffer() had size 0 instead of expected size 1
    ```
    
    The reason is that when do `spark.catalog.cacheTable("localRelation")`, `CacheManager` tries to cache for the plan wrapped by `SubqueryAlias` but when planning for the DataFrame `localRelation`, `CacheManager` tries to find cached table for the not-wrapped plan because the plan for DataFrame `localRelation` is not wrapped.
    Some plans like `LocalRelation`, `LogicalRDD`, etc. override `sameResult` method, but not use canonicalized plan to compare so the `CacheManager` can't detect the plans are the same.
    
    This pr modifies `CacheManager` to use canonicalized plan for planToCache.
    
    ## How was this patch tested?
    
    Added a test to check if DataFrame with plan overriding sameResult but not using canonicalized plan to compare can cacheTable.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ueshin/apache-spark issues/SPARK-15915

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/13638.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #13638
    
----
commit 9eb4c2537a7453ecce8c6e15153b1d94f000d477
Author: Takuya UESHIN <ue...@happy-camper.st>
Date:   2016-06-13T06:05:21Z

    Add a test to check if DataFrame with plan overriding sameResult but not using canonicalized plan to compare can cacheTable.

commit 52641f4612bd2a461ef678778f34b464a97d953d
Author: Takuya UESHIN <ue...@happy-camper.st>
Date:   2016-06-13T06:15:25Z

    Modify CacheManager to use canonicalized plan for planToCache.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] Logical plans should use canonicalize...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] CacheManager should use canonicalized...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    **[Test build #60389 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/60389/consoleFull)** for PR 13638 at commit [`52641f4`](https://github.com/apache/spark/commit/52641f4612bd2a461ef678778f34b464a97d953d).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] Logical plans should use canonicalize...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    **[Test build #60458 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/60458/consoleFull)** for PR 13638 at commit [`3d27607`](https://github.com/apache/spark/commit/3d27607982a3794c438221153b8e078389da146b).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13638: [SPARK-15915][SQL] Logical plans should use canon...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/13638


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] Logical plans should use canonicalize...

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    Updated pr title, description and a test name.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] Logical plans should use canonicalize...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/60451/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] Logical plans should use canonicalize...

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    @marmbrus Thank you for merging this.
    Sure, I'll send a backport pr for `branch-1.6`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] CacheManager should use canonicalized...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    Seems reasonable.  Is this a regression from 1.6?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] CacheManager should use canonicalized...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/60389/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] Logical plans should use canonicalize...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] Logical plans should use canonicalize...

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    @marmbrus I sent a backport pr #13668.
    But is `branch-1.6` build broken now?
    Looks working on #13630.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13638: [SPARK-15915][SQL] CacheManager should use canoni...

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13638#discussion_r66884468
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala ---
    @@ -155,8 +156,9 @@ private[sql] class CacheManager extends Logging {
        * function will over invalidate.
        */
       private[sql] def invalidateCache(plan: LogicalPlan): Unit = writeLock {
    +    val canonicalized = plan.canonicalized
         cachedData.foreach {
    -      case data if data.plan.collect { case p if p.sameResult(plan) => p }.nonEmpty =>
    +      case data if data.plan.collect { case p if p.sameResult(canonicalized) => p }.nonEmpty =>
    --- End diff --
    
    I see, I'll fix them, too.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] CacheManager should use canonicalized...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    this looks reasonable to me, cc @marmbrus is there any corner cases?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13638: [SPARK-15915][SQL] CacheManager should use canoni...

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13638#discussion_r66880127
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala ---
    @@ -155,8 +156,9 @@ private[sql] class CacheManager extends Logging {
        * function will over invalidate.
        */
       private[sql] def invalidateCache(plan: LogicalPlan): Unit = writeLock {
    +    val canonicalized = plan.canonicalized
         cachedData.foreach {
    -      case data if data.plan.collect { case p if p.sameResult(plan) => p }.nonEmpty =>
    +      case data if data.plan.collect { case p if p.sameResult(canonicalized) => p }.nonEmpty =>
    --- End diff --
    
    I don't think so.
    For example, if the cached plan is `LocalRelation` (which is canonicalized) and the `plan` argument is `SubqueryAlias(LocalRelation)` (which is not canonicalized), it will fail to find the same-result plan.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] Logical plans should use canonicalize...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    LGTM, @marmbrus  should be backport it to 1.6?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13638: [SPARK-15915][SQL] CacheManager should use canoni...

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13638#discussion_r66895037
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala ---
    @@ -87,7 +87,7 @@ private[sql] class CacheManager extends Logging {
           query: Dataset[_],
           tableName: Option[String] = None,
           storageLevel: StorageLevel = MEMORY_AND_DISK): Unit = writeLock {
    -    val planToCache = query.queryExecution.analyzed
    +    val planToCache = query.queryExecution.analyzed.canonicalized
    --- End diff --
    
    It seems we don't need them for now.
    I'll revert the changes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] CacheManager should use canonicalized...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    **[Test build #60451 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/60451/consoleFull)** for PR 13638 at commit [`11dc433`](https://github.com/apache/spark/commit/11dc433975719288a3694746c60a571d3f349b22).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] Logical plans should use canonicalize...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    **[Test build #60459 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/60459/consoleFull)** for PR 13638 at commit [`0c9ec86`](https://github.com/apache/spark/commit/0c9ec86f7e2646466b91d75b26dc29de31b98d31).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] Logical plans should use canonicalize...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    **[Test build #60459 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/60459/consoleFull)** for PR 13638 at commit [`0c9ec86`](https://github.com/apache/spark/commit/0c9ec86f7e2646466b91d75b26dc29de31b98d31).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13638: [SPARK-15915][SQL] CacheManager should use canoni...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13638#discussion_r66880856
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala ---
    @@ -155,8 +156,9 @@ private[sql] class CacheManager extends Logging {
        * function will over invalidate.
        */
       private[sql] def invalidateCache(plan: LogicalPlan): Unit = writeLock {
    +    val canonicalized = plan.canonicalized
         cachedData.foreach {
    -      case data if data.plan.collect { case p if p.sameResult(plan) => p }.nonEmpty =>
    +      case data if data.plan.collect { case p if p.sameResult(canonicalized) => p }.nonEmpty =>
    --- End diff --
    
    the implementation of `sameResult`:
    ```
    def sameResult(plan: PlanType): Boolean = {
        val left = this.canonicalized
        val right = plan.canonicalized
        ......
    ```
    Seems we do canonicalize plans?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] Logical plans should use canonicalize...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] Logical plans should use canonicalize...

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    @marmbrus It seems this is not a regression from `1.6`.
    The test modified for `1.6` also fails with the same error.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] Logical plans should use canonicalize...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/60458/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] Logical plans should use canonicalize...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    Hmmm, does not apply cleanly to 1.6.  @ueshin if you have time it might be nice to backport.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] CacheManager should use canonicalized...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13638: [SPARK-15915][SQL] CacheManager should use canoni...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13638#discussion_r66884087
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala ---
    @@ -155,8 +156,9 @@ private[sql] class CacheManager extends Logging {
        * function will over invalidate.
        */
       private[sql] def invalidateCache(plan: LogicalPlan): Unit = writeLock {
    +    val canonicalized = plan.canonicalized
         cachedData.foreach {
    -      case data if data.plan.collect { case p if p.sameResult(plan) => p }.nonEmpty =>
    +      case data if data.plan.collect { case p if p.sameResult(canonicalized) => p }.nonEmpty =>
    --- End diff --
    
    I guess I would prefer to fix in in `sameResult` if possible so that all uses of that function will benefit.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] CacheManager should use canonicalized...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    **[Test build #60389 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/60389/consoleFull)** for PR 13638 at commit [`52641f4`](https://github.com/apache/spark/commit/52641f4612bd2a461ef678778f34b464a97d953d).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] Logical plans should use canonicalize...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/60459/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13638: [SPARK-15915][SQL] CacheManager should use canoni...

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13638#discussion_r66881822
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala ---
    @@ -155,8 +156,9 @@ private[sql] class CacheManager extends Logging {
        * function will over invalidate.
        */
       private[sql] def invalidateCache(plan: LogicalPlan): Unit = writeLock {
    +    val canonicalized = plan.canonicalized
         cachedData.foreach {
    -      case data if data.plan.collect { case p if p.sameResult(plan) => p }.nonEmpty =>
    +      case data if data.plan.collect { case p if p.sameResult(canonicalized) => p }.nonEmpty =>
    --- End diff --
    
    Some plans like `LocalRelation`, `LogicalRDD`, etc. override the `sameResult` and it does not use canonicalized plan to compare.
    
    For example, `LocalRelation` overrides like as follows:
    
    ```
      override def sameResult(plan: LogicalPlan): Boolean = plan match {
        case LocalRelation(otherOutput, otherData) =>
          otherOutput.map(_.dataType) == output.map(_.dataType) && otherData == data
        case _ => false
      }
    ```
    
    If the `plan` is `SubqueryAlias(LocalRelation)`, the method returns `false`.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13638: [SPARK-15915][SQL] CacheManager should use canoni...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13638#discussion_r66876008
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala ---
    @@ -155,8 +156,9 @@ private[sql] class CacheManager extends Logging {
        * function will over invalidate.
        */
       private[sql] def invalidateCache(plan: LogicalPlan): Unit = writeLock {
    +    val canonicalized = plan.canonicalized
         cachedData.foreach {
    -      case data if data.plan.collect { case p if p.sameResult(plan) => p }.nonEmpty =>
    +      case data if data.plan.collect { case p if p.sameResult(canonicalized) => p }.nonEmpty =>
    --- End diff --
    
    I think this is redundant,  `sameResult` already compares the canonicalized plan.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13638: [SPARK-15915][SQL] CacheManager should use canoni...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13638#discussion_r66882083
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala ---
    @@ -155,8 +156,9 @@ private[sql] class CacheManager extends Logging {
        * function will over invalidate.
        */
       private[sql] def invalidateCache(plan: LogicalPlan): Unit = writeLock {
    +    val canonicalized = plan.canonicalized
         cachedData.foreach {
    -      case data if data.plan.collect { case p if p.sameResult(plan) => p }.nonEmpty =>
    +      case data if data.plan.collect { case p if p.sameResult(canonicalized) => p }.nonEmpty =>
    --- End diff --
    
    Should we just fix those implementations?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13638: [SPARK-15915][SQL] CacheManager should use canoni...

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13638#discussion_r66883158
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala ---
    @@ -155,8 +156,9 @@ private[sql] class CacheManager extends Logging {
        * function will over invalidate.
        */
       private[sql] def invalidateCache(plan: LogicalPlan): Unit = writeLock {
    +    val canonicalized = plan.canonicalized
         cachedData.foreach {
    -      case data if data.plan.collect { case p if p.sameResult(plan) => p }.nonEmpty =>
    +      case data if data.plan.collect { case p if p.sameResult(canonicalized) => p }.nonEmpty =>
    --- End diff --
    
    Hmm, yes, we should for now, but we can't force to use canonicalized plan and it is difficult to check all implementations so I thought `CacheManager` should canonicalize plans.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] CacheManager should use canonicalized...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    **[Test build #60458 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/60458/consoleFull)** for PR 13638 at commit [`3d27607`](https://github.com/apache/spark/commit/3d27607982a3794c438221153b8e078389da146b).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] Logical plans should use canonicalize...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    **[Test build #60451 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/60451/consoleFull)** for PR 13638 at commit [`11dc433`](https://github.com/apache/spark/commit/11dc433975719288a3694746c60a571d3f349b22).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13638: [SPARK-15915][SQL] CacheManager should use canoni...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13638#discussion_r66887975
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala ---
    @@ -87,7 +87,7 @@ private[sql] class CacheManager extends Logging {
           query: Dataset[_],
           tableName: Option[String] = None,
           storageLevel: StorageLevel = MEMORY_AND_DISK): Unit = writeLock {
    -    val planToCache = query.queryExecution.analyzed
    +    val planToCache = query.queryExecution.analyzed.canonicalized
    --- End diff --
    
    do we still need these changes? `LogicalPlan.canonicalized` is a lazy val and we don't have performance penalty even we use un-canonicalized plan as key.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13638: [SPARK-15915][SQL] Logical plans should use canonicalize...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on the issue:

    https://github.com/apache/spark/pull/13638
  
    Yeah, sounds reasonable.  Merging to master, 2.0 and 1.6.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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