GitHub user gatorsmile opened a pull request:

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

    ### What changes were proposed in this pull request?
    author: BoleynSu 
    val df = Seq((1, 1)).toDF("i", "j")
      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
    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 pr-18836

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

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 <>
Date:   2017-08-03T17:55:26Z

    Update SortMergeJoinExec.scala
    fix a bug in outputOrdering

commit f351fb1cbda8104f4f7e6ffa0be07f26b290683e
Author: Xiao Li <>
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 or file a JIRA ticket
with INFRA.

To unsubscribe, e-mail:
For additional commands, e-mail:

Reply via email to