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

    https://github.com/apache/spark/pull/14383#discussion_r72520586
  
    --- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/catalyst/LogicalPlanToSQLSuite.scala
 ---
    @@ -934,6 +934,159 @@ class LogicalPlanToSQLSuite extends SQLBuilderTest 
with SQLTestUtils {
         }
       }
     
    +  test("mapjoin_subquery") {
    +    checkSQL(
    +      """
    +        |SELECT subq.key1, z.value
    +        |FROM (SELECT x.key as key1, x.value as value1, y.key as key2, 
y.value as value2
    +        |      FROM src1 x JOIN src y ON (x.key = y.key)) subq
    +        |JOIN srcpart z ON (subq.key1 = z.key and z.ds='2008-04-08' and 
z.hr=11)
    +        |ORDER BY subq.key1, z.value
    +      """.stripMargin,
    +      "mapjoin_subquery")
    +  }
    +
    +  test("subq2") {
    +    checkSQL(
    +      """
    +        |SELECT a.k, a.c
    +        |FROM (SELECT b.key as k, count(1) as c
    +        |      FROM src b
    +        |      GROUP BY b.key) a
    +        |WHERE a.k >= 90
    +      """.stripMargin,
    +      "subq2")
    +  }
    +
    +  test("subquery_exists") {
    +    checkSQL(
    +      """
    +        |select *
    +        |from src b
    +        |where exists (select a.key
    +        |              from src a
    +        |              where b.value = a.value and a.key = b.key and 
a.value > 'val_9')
    +      """.stripMargin,
    +      "subquery_exists_1")
    +
    +    checkSQL(
    +      """
    +        |select *
    +        |from (select *
    +        |      from src b
    +        |      where exists (select a.key
    +        |                    from src a
    +        |                    where b.value = a.value and a.key = b.key and 
a.value > 'val_9')) a
    +      """.stripMargin,
    +      "subquery_exists_2")
    +  }
    +
    +  test("subquery_exists_having") {
    +    checkSQL(
    +      """
    +        |select b.key, count(*)
    +        |from src b
    +        |group by b.key
    +        |having exists (select a.key
    +        |               from src a
    +        |               where a.key = b.key and a.value > 'val_9')
    +      """.stripMargin,
    +      "subquery_exists_having_1")
    +
    +    checkSQL(
    +      """
    +        |select *
    +        |from (select b.key, count(*)
    +        |      from src b
    +        |      group by b.key
    +        |      having exists (select a.key
    +        |                     from src a
    +        |                     where a.key = b.key and a.value > 'val_9')) a
    +      """.stripMargin,
    +      "subquery_exists_having_2")
    +
    +    checkSQL(
    +      """
    +        |select b.key, min(b.value)
    +        |from src b
    +        |group by b.key
    +        |having exists (select a.key
    +        |               from src a
    +        |               where a.value > 'val_9' and a.value = min(b.value))
    +      """.stripMargin,
    +      "subquery_exists_having_3")
    +  }
    +
    +  test("subquery_notexists") {
    --- End diff --
    
    same thing for the following few tests.



---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to