gatorsmile commented on a change in pull request #24723: [SPARK-27857][SQL]
Move ALTER TABLE parsing into Catalyst
URL: https://github.com/apache/spark/pull/24723#discussion_r289689043
##########
File path:
sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4
##########
@@ -113,14 +113,26 @@ statement
LIKE source=tableIdentifier locationSpec?
#createTableLike
| ANALYZE TABLE tableIdentifier partitionSpec? COMPUTE STATISTICS
(identifier | FOR COLUMNS identifierSeq | FOR ALL COLUMNS)? #analyze
- | ALTER TABLE tableIdentifier
- ADD COLUMNS '(' columns=colTypeList ')'
#addTableColumns
+ | ALTER TABLE multipartIdentifier
+ ADD (COLUMN | COLUMNS) columns=newColumnList colPosition?
#addTableColumns
Review comment:
Below is the example you can follow
```
| ALTER TABLE tableIdentifier
ADD COLUMNS '(' columns=qualifiedColTypeWithPositionList ')'
#addTableColumns
qualifiedColTypeWithPositionList
: qualifiedColTypeWithPosition (',' qualifiedColTypeWithPosition)*
;
qualifiedColTypeWithPosition
: (path=qualifiedName '.')? colType colPosition?
;
colType <-- reuse the existing one
: identifier dataType (COMMENT STRING)?
```
----------------------------------------------------------------
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]