Skip to content

Commit

Permalink
NETFLIX-BUILD: Update parser and statements to unify CREATE.
Browse files Browse the repository at this point in the history
  • Loading branch information
rdblue committed Mar 25, 2020
1 parent f206bbd commit 51593cb
Show file tree
Hide file tree
Showing 6 changed files with 365 additions and 391 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ grammar SqlBase;
*/
public boolean legacy_exponent_literal_as_decimal_enabled = false;
/**
* When false, CREATE TABLE syntax without a provider will use
* the value of spark.sql.sources.default as its provider.
*/
public boolean legacy_create_hive_table_by_default_enabled = false;
/**
* Verify whether current token is a valid decimal token (which contains dot).
* Returns true if the character that follows the token is not a digit or letter or underscore.
Expand Down Expand Up @@ -123,33 +117,17 @@ statement
(RESTRICT | CASCADE)? #dropNamespace
| SHOW (DATABASES | NAMESPACES) ((FROM | IN) multipartIdentifier)?
(LIKE? pattern=STRING)? #showNamespaces
| {!legacy_create_hive_table_by_default_enabled}?
createTableHeader ('(' colTypeList ')')? tableProvider?
| createTableHeader ('(' colTypeList ')')? tableProvider?
createTableClauses
(AS? query)? #createTable
| {legacy_create_hive_table_by_default_enabled}?
createTableHeader ('(' colTypeList ')')? tableProvider
createTableClauses
(AS? query)? #createTable
| createTableHeader ('(' columns=colTypeList ')')?
(commentSpec |
(PARTITIONED BY '(' partitionColumns=colTypeList ')' |
PARTITIONED BY partitionColumnNames=identifierList) |
bucketSpec |
skewSpec |
rowFormat |
createFileFormat |
locationSpec |
(TBLPROPERTIES tableProps=tablePropertyList))*
(AS? query)? #createHiveTable
| CREATE TABLE (IF NOT EXISTS)? target=tableIdentifier
LIKE source=tableIdentifier
(tableProvider |
rowFormat |
createFileFormat |
locationSpec |
(TBLPROPERTIES tableProps=tablePropertyList))* #createTableLike
| replaceTableHeader ('(' colTypeList ')')? tableProvider
| replaceTableHeader ('(' colTypeList ')')? tableProvider?
createTableClauses
(AS? query)? #replaceTable
| ANALYZE TABLE multipartIdentifier partitionSpec? COMPUTE STATISTICS
Expand Down Expand Up @@ -384,8 +362,11 @@ tableProvider

createTableClauses
:((OPTIONS options=tablePropertyList) |
(PARTITIONED BY partitioning=transformList) |
(PARTITIONED BY partitioning=partitionFieldList) |
skewSpec |
bucketSpec |
rowFormat |
createFileFormat |
locationSpec |
commentSpec |
(TBLPROPERTIES tableProps=tablePropertyList))*
Expand Down Expand Up @@ -732,8 +713,13 @@ namedExpressionSeq
: namedExpression (',' namedExpression)*
;

transformList
: '(' transforms+=transform (',' transforms+=transform)* ')'
partitionFieldList
: '(' fields+=partitionField (',' fields+=partitionField)* ')'
;

partitionField
: transform #partitionTransform
| colType #partitionColumn
;

transform
Expand Down
Loading

0 comments on commit 51593cb

Please sign in to comment.