LantaoJin opened a new pull request #26097: [SPARK-29421][SQL] Supporting 
Create Table Like Stored as/Using FileFormat
URL: https://github.com/apache/spark/pull/26097
 
 
   ### What changes were proposed in this pull request?
   Hive support STORED AS new file format syntax:
   ```sql
   CREATE TABLE tbl(a int) STORED AS TEXTFILE;
   CREATE TABLE tbl2 LIKE tbl STORED AS PARQUET;
   ```
   In this PR, we add the similar syntax for Spark:
   Using `STORED AS file_format` to create new Hive table with new file format.
   Using `USING file_format` to create new data source table with new file 
format.
   
   ### Why are the changes needed?
   Use CREATE TABLE tb1 LIKE tb2 command to create an empty table tb1 based on 
the definition of table tb2. The most user case is to create tb1 with the same 
schema of tb2. But an inconvenient case here is this command also copies the 
FileFormat from tb2, it cannot change the input/output format and serde. Add 
the ability of changing file format is useful for some scenarios like upgrading 
a table from a low performance file format to a high performance one (parquet, 
orc).
   
   
   ### Does this PR introduce any user-facing change?
   Add a new syntax based on current CTL:
   When table is Hive table:
   ```sql
   CREATE TABLE tbl2 LIKE tbl STORED AS parquetfile;
   ```
   When table is data source table:
   ```sql
   CREATE TABLE tbl2 LIKE tbl USING parquet;
   ```
   It still keeps the same behaviour without providing file format – copying 
the file format from source table.
   ```sql
   CREATE TABLE tbl2 LIKE tbl;
   ```
   
   ### How was this patch tested?
   Modify some exist UTs.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to