You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by wzhfy <gi...@git.apache.org> on 2017/03/17 07:11:34 UTC

[GitHub] spark pull request #17331: [SPARK-19994][SQL] Wrong outputOrdering for right...

GitHub user wzhfy opened a pull request:

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

    [SPARK-19994][SQL] Wrong outputOrdering for right/full outer smj

    ## What changes were proposed in this pull request?
    
    For right outer join, values of the left key will be filled with nulls if it can't match the value of the right key, so `nullOrdering` of the left key can't be guaranteed. We should output right key order.
    
    For full outer join, neither left key nor right key guarantees `nullOrdering`. We should not output any ordering.
    
    This patch also reorganizes code in `PlannerSuite` by separating tests for `Exchange` and `Sort`, and also extracts common logic in Sort tests into a method.
    
    ## How was this patch tested?
    
    Corresponding test cases added.


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

    $ git pull https://github.com/wzhfy/spark wrongOrdering

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

    https://github.com/apache/spark/pull/17331.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 #17331
    
----
commit 8dc2c046d32df84626470303ea97180a1091684b
Author: wangzhenhua <wa...@huawei.com>
Date:   2017-03-17T06:58:10Z

    wrong outputOrdering for right/full outer smj

----


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right...

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

    https://github.com/apache/spark/pull/17331#discussion_r106798699
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/joins/SortMergeJoinExec.scala ---
    @@ -80,7 +80,18 @@ case class SortMergeJoinExec(
       override def requiredChildDistribution: Seq[Distribution] =
         ClusteredDistribution(leftKeys) :: ClusteredDistribution(rightKeys) :: Nil
     
    -  override def outputOrdering: Seq[SortOrder] = requiredOrders(leftKeys)
    +  override def outputOrdering: Seq[SortOrder] = joinType match {
    +    case RightOuter =>
    +      // For right outer join, values of the left key will be filled with nulls if it can't
    +      // match the value of the right key, so `nullOrdering` of the left key can't be guaranteed.
    +      // We should output right key order here.
    +      requiredOrders(rightKeys)
    +    case FullOuter =>
    +      // Neither left key nor right key guarantees `nullOrdering` after full outer join.
    +      Nil
    +    case _ =>
    --- End diff --
    
    If possible, please use the white list. Otherwise, we might forget to update this when adding new join types. Then, we should issue the exception for the default case. 


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

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


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    The bug was introduced when we merge `SortMergeJoin` and `SortMergerOuterJoin`
    
    https://github.com/apache/spark/pull/11743/files#diff-b669f8cf35f1d2d786582f4d8c49ed14



---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    It seems this breaks the build in 2.0 https://amplab.cs.berkeley.edu/jenkins/job/spark-branch-2.0-compile-maven-hadoop-2.7/lastBuild/console
    ```
    [error] /home/jenkins/workspace/SparkPullRequestBuilder/sql/core/src/main/scala/org/apache/spark/sql/execution/joins/SortMergeJoinExec.scala:87: not found: type InnerLike
    [error]     case _: InnerLike | LeftExistence(_) => requiredOrders(leftKeys)
    [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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    **[Test build #74817 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74817/testReport)** for PR 17331 at commit [`e4c41dc`](https://github.com/apache/spark/commit/e4c41dcbca9afdcce5ebe44836f5f8cef0a01bb4).


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    cc @cloud-fan @hvanhovell 


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    retest this please


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    **[Test build #74817 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74817/testReport)** for PR 17331 at commit [`e4c41dc`](https://github.com/apache/spark/commit/e4c41dcbca9afdcce5ebe44836f5f8cef0a01bb4).
     * This patch **fails Spark unit 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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    **[Test build #74809 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74809/testReport)** for PR 17331 at commit [`e4c41dc`](https://github.com/apache/spark/commit/e4c41dcbca9afdcce5ebe44836f5f8cef0a01bb4).


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    retest this please


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    thanks, merging to master/2.1/2.0!


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    **[Test build #74835 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74835/testReport)** for PR 17331 at commit [`e4c41dc`](https://github.com/apache/spark/commit/e4c41dcbca9afdcce5ebe44836f5f8cef0a01bb4).
     * 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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

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


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/74731/
    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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right...

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

    https://github.com/apache/spark/pull/17331#discussion_r106797733
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/joins/SortMergeJoinExec.scala ---
    @@ -80,7 +80,18 @@ case class SortMergeJoinExec(
       override def requiredChildDistribution: Seq[Distribution] =
         ClusteredDistribution(leftKeys) :: ClusteredDistribution(rightKeys) :: Nil
     
    -  override def outputOrdering: Seq[SortOrder] = requiredOrders(leftKeys)
    +  override def outputOrdering: Seq[SortOrder] = joinType match {
    +    case RightOuter =>
    +      // For right outer join, values of the left key will be filled with nulls if it can't
    +      // match the value of the right key, so `nullOrdering` of the left key can't be guaranteed.
    +      // We should output right key order here.
    --- End diff --
    
    OK I'll use those comments in the original PR.


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    Merged build finished. Test FAILed.


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    @wzhfy Thank you so much.


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    **[Test build #74731 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74731/testReport)** for PR 17331 at commit [`8dc2c04`](https://github.com/apache/spark/commit/8dc2c046d32df84626470303ea97180a1091684b).


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right...

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

    https://github.com/apache/spark/pull/17331#discussion_r106797512
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/joins/SortMergeJoinExec.scala ---
    @@ -80,7 +80,18 @@ case class SortMergeJoinExec(
       override def requiredChildDistribution: Seq[Distribution] =
         ClusteredDistribution(leftKeys) :: ClusteredDistribution(rightKeys) :: Nil
     
    -  override def outputOrdering: Seq[SortOrder] = requiredOrders(leftKeys)
    +  override def outputOrdering: Seq[SortOrder] = joinType match {
    +    case RightOuter =>
    +      // For right outer join, values of the left key will be filled with nulls if it can't
    +      // match the value of the right key, so `nullOrdering` of the left key can't be guaranteed.
    +      // We should output right key order here.
    --- End diff --
    
    > // For left and right outer joins, the output is ordered by the streamed input's join keys.


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right...

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

    https://github.com/apache/spark/pull/17331#discussion_r106782184
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/PlannerSuite.scala ---
    @@ -557,6 +470,130 @@ class PlannerSuite extends SharedSQLContext {
           fail(s"Should have only two shuffles:\n$outputPlan")
         }
       }
    +
    +  ///////////////////////////////////////////////////////////////////////////
    +  // Unit tests of EnsureRequirements for Sort
    +  ///////////////////////////////////////////////////////////////////////////
    +
    +  private val exprA = Literal(1)
    +  private val exprB = Literal(2)
    +  private val orderingA = SortOrder(exprA, Ascending)
    +  private val orderingB = SortOrder(exprB, Ascending)
    +  private val planA = DummySparkPlan(outputOrdering = Seq(orderingA),
    +    outputPartitioning = HashPartitioning(exprA :: Nil, 5))
    +  private val planB = DummySparkPlan(outputOrdering = Seq(orderingB),
    +    outputPartitioning = HashPartitioning(exprB :: Nil, 5))
    +
    +  assert(orderingA != orderingB)
    +
    +  private def assertSortRequirementsAreSatisfied(
    +      childPlan: SparkPlan,
    +      requiredOrdering: Seq[SortOrder],
    +      shouldHaveSort: Boolean): Unit = {
    +    val inputPlan = DummySparkPlan(
    +      children = childPlan :: Nil,
    +      requiredChildOrdering = Seq(requiredOrdering),
    +      requiredChildDistribution = Seq(UnspecifiedDistribution)
    +    )
    +    val outputPlan = EnsureRequirements(spark.sessionState.conf).apply(inputPlan)
    +    assertDistributionRequirementsAreSatisfied(outputPlan)
    +    if (shouldHaveSort) {
    +      if (outputPlan.collect { case s: SortExec => true }.isEmpty) {
    +        fail(s"Sort should have been added:\n$outputPlan")
    +      }
    +    } else {
    +      if (outputPlan.collect { case s: SortExec => true }.nonEmpty) {
    +        fail(s"No sorts should have been added:\n$outputPlan")
    +      }
    +    }
    +  }
    +
    +  test("EnsureRequirements for sort operator after left outer sort merge join") {
    --- End diff --
    
    I added three test cases for left/right/full outer join. For other tests, I moved tests about sort together and extract common logic to a method and some private fields.


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right...

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/17331#discussion_r106775256
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/PlannerSuite.scala ---
    @@ -557,6 +470,130 @@ class PlannerSuite extends SharedSQLContext {
           fail(s"Should have only two shuffles:\n$outputPlan")
         }
       }
    +
    +  ///////////////////////////////////////////////////////////////////////////
    +  // Unit tests of EnsureRequirements for Sort
    +  ///////////////////////////////////////////////////////////////////////////
    +
    +  private val exprA = Literal(1)
    +  private val exprB = Literal(2)
    +  private val orderingA = SortOrder(exprA, Ascending)
    +  private val orderingB = SortOrder(exprB, Ascending)
    +  private val planA = DummySparkPlan(outputOrdering = Seq(orderingA),
    +    outputPartitioning = HashPartitioning(exprA :: Nil, 5))
    +  private val planB = DummySparkPlan(outputOrdering = Seq(orderingB),
    +    outputPartitioning = HashPartitioning(exprB :: Nil, 5))
    +
    +  assert(orderingA != orderingB)
    +
    +  private def assertSortRequirementsAreSatisfied(
    +      childPlan: SparkPlan,
    +      requiredOrdering: Seq[SortOrder],
    +      shouldHaveSort: Boolean): Unit = {
    +    val inputPlan = DummySparkPlan(
    +      children = childPlan :: Nil,
    +      requiredChildOrdering = Seq(requiredOrdering),
    +      requiredChildDistribution = Seq(UnspecifiedDistribution)
    +    )
    +    val outputPlan = EnsureRequirements(spark.sessionState.conf).apply(inputPlan)
    +    assertDistributionRequirementsAreSatisfied(outputPlan)
    +    if (shouldHaveSort) {
    +      if (outputPlan.collect { case s: SortExec => true }.isEmpty) {
    +        fail(s"Sort should have been added:\n$outputPlan")
    +      }
    +    } else {
    +      if (outputPlan.collect { case s: SortExec => true }.nonEmpty) {
    +        fail(s"No sorts should have been added:\n$outputPlan")
    +      }
    +    }
    +  }
    +
    +  test("EnsureRequirements for sort operator after left outer sort merge join") {
    --- End diff --
    
    are we just moving test around?


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right...

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

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


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right...

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

    https://github.com/apache/spark/pull/17331#discussion_r106797210
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/joins/SortMergeJoinExec.scala ---
    @@ -80,7 +80,18 @@ case class SortMergeJoinExec(
       override def requiredChildDistribution: Seq[Distribution] =
         ClusteredDistribution(leftKeys) :: ClusteredDistribution(rightKeys) :: Nil
     
    -  override def outputOrdering: Seq[SortOrder] = requiredOrders(leftKeys)
    +  override def outputOrdering: Seq[SortOrder] = joinType match {
    +    case RightOuter =>
    +      // For right outer join, values of the left key will be filled with nulls if it can't
    +      // match the value of the right key, so `nullOrdering` of the left key can't be guaranteed.
    +      // We should output right key order here.
    +      requiredOrders(rightKeys)
    --- End diff --
    
    This is output ordering, right? The join result will be returned based on right keys?


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    @HyukjinKwon branch2.0 doesn't have InnerLike, I'll fix this.


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    **[Test build #74731 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74731/testReport)** for PR 17331 at commit [`8dc2c04`](https://github.com/apache/spark/commit/8dc2c046d32df84626470303ea97180a1091684b).
     * 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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right...

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

    https://github.com/apache/spark/pull/17331#discussion_r106797457
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/joins/SortMergeJoinExec.scala ---
    @@ -80,7 +80,18 @@ case class SortMergeJoinExec(
       override def requiredChildDistribution: Seq[Distribution] =
         ClusteredDistribution(leftKeys) :: ClusteredDistribution(rightKeys) :: Nil
     
    -  override def outputOrdering: Seq[SortOrder] = requiredOrders(leftKeys)
    +  override def outputOrdering: Seq[SortOrder] = joinType match {
    +    case RightOuter =>
    +      // For right outer join, values of the left key will be filled with nulls if it can't
    +      // match the value of the right key, so `nullOrdering` of the left key can't be guaranteed.
    +      // We should output right key order here.
    --- End diff --
    
    This comment is misleading. The output ordering is mainly affected by how we implement SortMergeJoinExec. 


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/74835/
    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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    Merged build finished. Test FAILed.


---
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 #17331: [SPARK-19994][SQL] Wrong outputOrdering for right/full o...

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

    https://github.com/apache/spark/pull/17331
  
    **[Test build #74835 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74835/testReport)** for PR 17331 at commit [`e4c41dc`](https://github.com/apache/spark/commit/e4c41dcbca9afdcce5ebe44836f5f8cef0a01bb4).


---
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