You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by gatorsmile <gi...@git.apache.org> on 2017/03/05 08:01:22 UTC

[GitHub] spark pull request #16762: [SPARK-19419] [SPARK-19420] Fix the cross join de...

Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16762#discussion_r104306401
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/JoinSuite.scala ---
    @@ -584,24 +602,39 @@ class JoinSuite extends QueryTest with SharedSQLContext {
         val cartesianQueries = Seq(
           /** The following should error out since there is no explicit cross join */
           "SELECT * FROM testData inner join testData2",
    -      "SELECT * FROM testData left outer join testData2",
    -      "SELECT * FROM testData right outer join testData2",
    -      "SELECT * FROM testData full outer join testData2",
    +
           "SELECT * FROM testData, testData2",
           "SELECT * FROM testData, testData2 where testData.key = 1 and testData2.a = 22",
    +      "SELECT * FROM testData, testData2 where testData.key > testData2.a",
    +      "SELECT * FROM testData INNER JOIN testData2 ON testData.key + testData2.a = testData2.b",
           /** The following should fail because after reordering there are cartesian products */
           "select * from (A join B on (A.key = B.key)) join D on (A.key=D.a) join C",
           "select * from ((A join B on (A.key = B.key)) join C) join D on (A.key = D.a)",
           /** Cartesian product involving C, which is not involved in a CROSS join */
    -      "select * from ((A join B on (A.key = B.key)) cross join D) join C on (A.key = D.a)");
    +      "select * from ((A join B on (A.key = B.key)) cross join D) join C on (A.key = D.a)")
     
    -     def checkCartesianDetection(query: String): Unit = {
    -      val e = intercept[Exception] {
    -        checkAnswer(sql(query), Nil);
    -      }
    -      assert(e.getMessage.contains("Detected cartesian product"))
    +    def checkCartesianDetection(query: String): Unit = {
    +      val e = intercept[AnalysisException](sql(query).collect()).getMessage
    +      assert(e.contains("Detected cartesian product"))
         }
     
         cartesianQueries.foreach(checkCartesianDetection)
    +
    +    val broadcastNestedLoopJoinOutOfBroadcastThresholdQueries = Seq(
    +      /** The following should error out since the flag spark.sql.crossJoin.enabled is not on */
    +      "SELECT * FROM testData left outer join testData2",
    +      "SELECT * FROM testData right outer join testData2",
    +      "SELECT * FROM testData full outer join testData2",
    +      "SELECT * FROM testData full outer join testData2 on testData.key > testData2.a",
    +      "SELECT b FROM testData2 WHERE EXISTS(SELECT a FROM testData3)"
    --- End diff --
    
    This is a subquery that will use `BroadcastNestedLoopJoin`.


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