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

gabrywu commented on SPARK-28329:
---------------------------------

[~smilegator] Is there a plan to support that? select into a scalar variable? I 
think it's useful to optimize some SQLs like this
{code:SQL}
select max(id) into ${max_id} from db.tableA;
select * from db.tableB where id >= ${max_id};
{code}
It's better than the following SQL, because it can push down the filters id >= 
${max_id}
{code:SQL}
select * from db.tableB where id >= (select max(id) from db.tableA);
{code}

> SELECT INTO syntax
> ------------------
>
>                 Key: SPARK-28329
>                 URL: https://issues.apache.org/jira/browse/SPARK-28329
>             Project: Spark
>          Issue Type: Sub-task
>          Components: SQL
>    Affects Versions: 3.1.0
>            Reporter: Yuming Wang
>            Priority: Major
>
> h2. Synopsis
> {noformat}
> [ WITH [ RECURSIVE ] with_query [, ...] ]
> SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
>     * | expression [ [ AS ] output_name ] [, ...]
>     INTO [ TEMPORARY | TEMP | UNLOGGED ] [ TABLE ] new_table
>     [ FROM from_item [, ...] ]
>     [ WHERE condition ]
>     [ GROUP BY expression [, ...] ]
>     [ HAVING condition [, ...] ]
>     [ WINDOW window_name AS ( window_definition ) [, ...] ]
>     [ { UNION | INTERSECT | EXCEPT } [ ALL | DISTINCT ] select ]
>     [ ORDER BY expression [ ASC | DESC | USING operator ] [ NULLS { FIRST | 
> LAST } ] [, ...] ]
>     [ LIMIT { count | ALL } ]
>     [ OFFSET start [ ROW | ROWS ] ]
>     [ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY ]
>     [ FOR { UPDATE | SHARE } [ OF table_name [, ...] ] [ NOWAIT ] [...] ]
> {noformat}
> h2. Description
> {{SELECT INTO}} creates a new table and fills it with data computed by a 
> query. The data is not returned to the client, as it is with a normal 
> {{SELECT}}. The new table's columns have the names and data types associated 
> with the output columns of the {{SELECT}}.
>  
> {{CREATE TABLE AS}} offers a superset of the functionality offered by 
> {{SELECT INTO}}.
> [https://www.postgresql.org/docs/11/sql-selectinto.html]
>  [https://www.postgresql.org/docs/11/sql-createtableas.html]



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

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

Reply via email to