aboutsummaryrefslogtreecommitdiff
path: root/sql/catalyst/src
diff options
context:
space:
mode:
authorLiang-Chi Hsieh <simonh@tw.ibm.com>2016-04-14 11:08:08 -0700
committerAndrew Or <andrew@databricks.com>2016-04-14 11:08:08 -0700
commit28efdd3fd789fa2ebed5be03b36ca0f682e37669 (patch)
tree0c354cfde01c380c63d27b507a702c30616f6ce6 /sql/catalyst/src
parentc971aee40d806ed02d3d6a5cc478b63654052e54 (diff)
downloadspark-28efdd3fd789fa2ebed5be03b36ca0f682e37669.tar.gz
spark-28efdd3fd789fa2ebed5be03b36ca0f682e37669.tar.bz2
spark-28efdd3fd789fa2ebed5be03b36ca0f682e37669.zip
[SPARK-14592][SQL] Native support for CREATE TABLE LIKE DDL command
## What changes were proposed in this pull request? JIRA: https://issues.apache.org/jira/browse/SPARK-14592 This patch adds native support for DDL command `CREATE TABLE LIKE`. The SQL syntax is like: CREATE TABLE table_name LIKE existing_table CREATE TABLE IF NOT EXISTS table_name LIKE existing_table ## How was this patch tested? `HiveDDLCommandSuite`. `HiveQuerySuite` already tests `CREATE TABLE LIKE`. Author: Liang-Chi Hsieh <simonh@tw.ibm.com> This patch had conflicts when merged, resolved by Committer: Andrew Or <andrew@databricks.com> Closes #12362 from viirya/create-table-like.
Diffstat (limited to 'sql/catalyst/src')
-rw-r--r--sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g47
1 files changed, 3 insertions, 4 deletions
diff --git a/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4 b/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4
index a937ad1eb7..9cf2dd257e 100644
--- a/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4
+++ b/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4
@@ -55,6 +55,8 @@ statement
rowFormat? createFileFormat? locationSpec?
(TBLPROPERTIES tablePropertyList)?
(AS? query)? #createTable
+ | CREATE TABLE (IF NOT EXISTS)? target=tableIdentifier
+ LIKE source=tableIdentifier #createTableLike
| ANALYZE TABLE tableIdentifier partitionSpec? COMPUTE STATISTICS
(identifier | FOR COLUMNS identifierSeq?)? #analyze
| ALTER (TABLE | VIEW) from=tableIdentifier
@@ -136,10 +138,7 @@ statement
;
hiveNativeCommands
- : createTableHeader LIKE tableIdentifier
- rowFormat? createFileFormat? locationSpec?
- (TBLPROPERTIES tablePropertyList)?
- | DELETE FROM tableIdentifier (WHERE booleanExpression)?
+ : DELETE FROM tableIdentifier (WHERE booleanExpression)?
| TRUNCATE TABLE tableIdentifier partitionSpec?
(COLUMNS identifierList)?
| SHOW COLUMNS (FROM | IN) tableIdentifier ((FROM|IN) identifier)?