spark-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wenchen Fan (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (SPARK-27209) Split parsing of SELECT and INSERT into two top-level rules in the grammar file.
Date Tue, 26 Mar 2019 00:44:00 GMT

     [ https://issues.apache.org/jira/browse/SPARK-27209?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Wenchen Fan resolved SPARK-27209.
---------------------------------
       Resolution: Fixed
    Fix Version/s: 3.0.0

Issue resolved by pull request 24150
[https://github.com/apache/spark/pull/24150]

> Split parsing of SELECT and INSERT into two top-level rules in the grammar file.
> --------------------------------------------------------------------------------
>
>                 Key: SPARK-27209
>                 URL: https://issues.apache.org/jira/browse/SPARK-27209
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 2.4.0
>            Reporter: Dilip Biswal
>            Assignee: Dilip Biswal
>            Priority: Major
>             Fix For: 3.0.0
>
>
> Currently in the grammar file the rule `query` is responsible to parse both select and
insert statements. As a result, we need to have more semantic checks in the code to guard
against in valid insert constructs in a query. Couple of examples are in the `visitCreateView`
and `visitAlterView` functions. One other issue is that, we don't catch the `invalid insert
constructs` in all the places. Here are couple of examples :
> {code:sql}
> select * from (insert into bar values (2));
> {code}
> {code:scala}
> Error in query: unresolved operator 'Project [*];
> 'Project [*]
> +- SubqueryAlias `__auto_generated_subquery_name`
>    +- InsertIntoHiveTable `default`.`bar`, org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe,
false, false, [c1]
>       +- Project [cast(col1#18 as int) AS c1#20]
>          +- LocalRelation [col1#18]
> {code}
> {code:sql}
> select * from foo where c1 in (insert into bar values (2))
> {code}
> {code:scala}
> Error in query: cannot resolve '(default.foo.`c1` IN (listquery()))' due to data type
mismatch: 
> The number of columns in the left hand side of an IN subquery does not match the
> number of columns in the output of subquery.
> #columns in left hand side: 1.
> #columns in right hand side: 0.
> Left side columns:
> [default.foo.`c1`].
> Right side columns:
> [].;;
> 'Project [*]
> +- 'Filter c1#6 IN (list#5 [])
>    :  +- InsertIntoHiveTable `default`.`bar`, org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe,
false, false, [c1]
>    :     +- Project [cast(col1#7 as int) AS c1#9]
>    :        +- LocalRelation [col1#7]
>    +- SubqueryAlias `default`.`foo`
>       +- HiveTableRelation `default`.`foo`, org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe,
[c1#6]
> {code}
> We should have two top-level parser rules to parse `SELECT` and `INSERT` respectively.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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


Mime
View raw message