spark-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nattavut Sutyanyong (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SPARK-18603) Support `OuterReference` in projection list of IN correlated subqueries
Date Mon, 12 Dec 2016 17:01:58 GMT

    [ https://issues.apache.org/jira/browse/SPARK-18603?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15742455#comment-15742455
] 

Nattavut Sutyanyong commented on SPARK-18603:
---------------------------------------------

More examples:

{code:sql}
-- A silly subquery
SELECT *
FROM   A
WHERE  A.a1 IN (SELECT MAX(A.a2) FROM B)
{code}

{code:sql}
SELECT *
FROM   A
WHERE  A.value IN (SELECT CASE 
                          WHEN A.key1 is not null THEN B.v1
                          WHEN A.key2 is not null THEN B.v2
                          ELSE NULL END
                    FROM  B
                    WHERE A.ID = B.ID)
{code}

> Support `OuterReference` in projection list of IN correlated subqueries
> -----------------------------------------------------------------------
>
>                 Key: SPARK-18603
>                 URL: https://issues.apache.org/jira/browse/SPARK-18603
>             Project: Spark
>          Issue Type: Sub-task
>          Components: SQL
>    Affects Versions: 2.0.2
>            Reporter: Dongjoon Hyun
>
> This issue aims to allow OuterReference columns in projection lists of IN correlated
subqueries. 
> *SIMPLE EXAMPLE*
> {code}
> scala> sql("CREATE TEMPORARY VIEW t1 AS SELECT * FROM VALUES 1, 2 AS t1(a)")
> scala> sql("CREATE TEMPORARY VIEW t2 AS SELECT * FROM VALUES 1 AS t2(b)")
> scala> sql("SELECT a FROM t1 WHERE a IN (SELECT a FROM t2)").show
> {code}
> *COMPLEX EXAMPLE*
> {code}
> SELECT *
> FROM t1
> WHERE a IN (SELECT x
>             FROM (SELECT b, a + 1 as x, a + b as y
>                   FROM t2)
>             WHERE y > 0)
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org


Mime
View raw message