GitHub user gatorsmile opened a pull request:

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

    [SPARK-21647] [SQL] Fix SortMergeJoin when using CROSS

    ### What changes were proposed in this pull request?
    author: BoleynSu 
    closes https://github.com/apache/spark/pull/18836
    
    ```Scala
    val df = Seq((1, 1)).toDF("i", "j")
    df.createOrReplaceTempView("T")
    withSQLConf(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1") {
      sql("select * from (select a.i from T a cross join T t where t.i = a.i) 
as t1 " +
        "cross join T t2 where t2.i = t1.i").explain(true)
    }
    ```
    The above code could cause the following exception:
    ```
    SortMergeJoinExec should not take Cross as the JoinType
    java.lang.IllegalArgumentException: SortMergeJoinExec should not take Cross 
as the JoinType
        at 
org.apache.spark.sql.execution.joins.SortMergeJoinExec.outputOrdering(SortMergeJoinExec.scala:100)
    ```
    
    Our SortMergeJoinExec supports CROSS. We should not hit such an exception. 
This PR is to fix the issue.
    
    ### How was this patch tested?
    Modified the two existing test cases.

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

    $ git pull https://github.com/gatorsmile/spark pr-18836

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

    https://github.com/apache/spark/pull/18863.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 #18863
    
----
commit 54ba6bedb36e57698404dbaccb7d5639bf64770c
Author: Boleyn Su <boleyn...@gmail.com>
Date:   2017-08-03T17:55:26Z

    Update SortMergeJoinExec.scala
    
    fix a bug in outputOrdering

commit f351fb1cbda8104f4f7e6ffa0be07f26b290683e
Author: Xiao Li <gatorsm...@gmail.com>
Date:   2017-08-07T00:49:33Z

    added test 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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to