GitHub user dilipbiswal opened a pull request:
https://github.com/apache/spark/pull/15968
[SPARK-18533] Raise correct error upon specification of schema for
datasource tables created using CTAS
## What changes were proposed in this pull request?
Fixes the inconsistency of error raised between data source and hive serde
tables when schema is specified in CTAS scenario. In the process the
grammer for
create table (datasource) is simplified.
**before**
``` SQL
spark-sql> create table t2 (c1 int, c2 int) using parquet as select * from
t1;
Error in query:
mismatched input 'as' expecting {<EOF>, '.', 'OPTIONS', 'CLUSTERED',
'PARTITIONED'}(line 1, pos 64)
== SQL ==
explain extended create table t2 (c1 int, c2 int) using parquet as select *
from t1
----------------------------------------------------------------^^^
```
**After**
spark-sql> create table t2 (c1 int, c2 int) using parquet as select * from
t1
> ;
Error in query:
Operation not allowed: Schema may not be specified in a Create Table As
Select (CTAS) statement(line 1, pos 0)
== SQL ==
create table t2 (c1 int, c2 int) using parquet as select * from t1
^^^
```
## How was this patch tested?
Added a new test in CreateTableAsSelectSuite
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/dilipbiswal/spark ctas
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/15968.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #15968
----
----
---
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]