luoyuxia commented on code in PR #19545:
URL: https://github.com/apache/flink/pull/19545#discussion_r857373139
##########
flink-table/flink-sql-parser/src/main/codegen/includes/parserImpls.ftl:
##########
@@ -574,13 +575,18 @@ SqlAlterTable SqlAlterTable() :
startPos.plus(getPos()));
}
|
- <DROP> <CONSTRAINT>
- constraintName = SimpleIdentifier() {
- return new SqlAlterTableDropConstraint(
- tableIdentifier,
- constraintName,
- startPos.plus(getPos()));
- }
+ <DROP>
+ (
+ <CONSTRAINT> constraintName = SimpleIdentifier() {
+ return new SqlAlterTableDropConstraint(
+ tableIdentifier,
+ constraintName,
+ startPos.plus(getPos()));
+ }
+ |
+ [ <IF> <EXISTS> { ifExists = true; } ]
Review Comment:
Should it be `<IF> <EXISTS> <PARTITION>`? what if a sql statement like
`alter table drop table`? Seems it will also fall back to `SqlDropPartitions`.
Maybe it's a little confused that any `drop` except for `CONSTRAINT` will
fall back to `SqlDropPartitions`. It may bring some complexity when try to
support other `drop`.
##########
flink-table/flink-sql-parser/src/main/codegen/includes/parserImpls.ftl:
##########
@@ -595,6 +601,38 @@ SqlAlterTable SqlAlterTable() :
)
}
+/**
+* ALTER TABLE table_name DROP [IF EXISTS] PARTITION partition_spec[, PARTITION
partition_spec, ...]
Review Comment:
nit:
```suggestion
* ALTER TABLE table_identifier DROP [IF EXISTS] PARTITION partition_spec[,
PARTITION partition_spec, ...]
```
##########
flink-table/flink-sql-parser/src/test/java/org/apache/flink/sql/parser/FlinkSqlParserImplTest.java:
##########
@@ -338,6 +338,26 @@ void testAlterTableCompact() {
.fails("(?s).*Encountered \"\\)\" at line 1, column 26.\n.*");
}
+ @Test
+ public void testDropPartition() {
+ sql("alter table tbl drop if exists partition (p=1)")
Review Comment:
nit: add a test for alter table like `c1.d1.tbl`.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]