Skip to content

Commit

Permalink
Add subquery using IN on where clause.
Browse files Browse the repository at this point in the history
  • Loading branch information
dongjoon-hyun committed Jul 27, 2016
1 parent 9a49580 commit d7d70e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sql/hive/src/test/resources/sqlgen/subquery_in.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- This file is automatically generated by LogicalPlanToSQLSuite.
SELECT key
FROM src
WHERE key in (SELECT max(key) FROM src)
--------------------------------------------------------------------------------
SELECT `gen_attr_0` AS `key` FROM (SELECT `gen_attr_0` FROM (SELECT `key` AS `gen_attr_0`, `value` AS `gen_attr_2` FROM `default`.`src`) AS gen_subquery_0 WHERE (`gen_attr_0` IN (SELECT `gen_attr_3` AS `_c0` FROM (SELECT `gen_attr_1` AS `gen_attr_3` FROM (SELECT max(`gen_attr_4`) AS `gen_attr_1` FROM (SELECT `key` AS `gen_attr_4`, `value` AS `gen_attr_5` FROM `default`.`src`) AS gen_subquery_2) AS gen_subquery_1) AS gen_subquery_3))) AS src
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,16 @@ class LogicalPlanToSQLSuite extends SQLBuilderTest with SQLTestUtils {
"subquery_not_exists_having_2")
}

test("subquery using IN on where clause") {
checkSQL(
"""
|SELECT key
|FROM src
|WHERE key in (SELECT max(key) FROM src)
""".stripMargin,
"subquery_in")
}

test("subquery using IN on having clause") {
checkSQL(
"""
Expand Down

0 comments on commit d7d70e6

Please sign in to comment.