You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/04/25 08:50:14 UTC

[GitHub] [flink] luoyuxia commented on a diff in pull request #19545: [FLINK-27241][table] Support DROP PARTITION statement for partitioned table

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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org