Skip to content

Commit

Permalink
[FLINK-22408][sql-parser] Fix SqlDropPartitions unparse Error
Browse files Browse the repository at this point in the history
This closes apache#15894
  • Loading branch information
aidenma-develop authored and lirui-apache committed May 12, 2021
1 parent 3a1b2e1 commit 3b5f399
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,16 @@ public void testDropPartition() {
.ok(
"ALTER TABLE `TBL`\n"
+ "DROP\n"
+ "PARTITION (`P1` = 'a', `P2` = 1)\n"
+ "PARTITION (`P1` = 'a', `P2` = 1),\n"
+ "PARTITION (`P1` = 'b', `P2` = 2)");
sql("alter table tbl drop partition (p1='a',p2=1), "
+ "partition(p1='b',p2=2), partition(p1='c',p2=3)")
.ok(
"ALTER TABLE `TBL`\n"
+ "DROP\n"
+ "PARTITION (`P1` = 'a', `P2` = 1),\n"
+ "PARTITION (`P1` = 'b', `P2` = 2),\n"
+ "PARTITION (`P1` = 'c', `P2` = 3)");
// TODO: support IGNORE PROTECTION, PURGE
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
}
int opLeftPrec = getOperator().getLeftPrec();
int opRightPrec = getOperator().getRightPrec();
final SqlWriter.Frame frame = writer.startList("", "");
for (SqlNodeList partSpec : partSpecs) {
writer.sep(",");
writer.newlineAndIndent();
writer.keyword("PARTITION");
partSpec.unparse(writer, opLeftPrec, opRightPrec);
}
writer.endList(frame);
}

@Nonnull
Expand Down

0 comments on commit 3b5f399

Please sign in to comment.