This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 0850bf3a263 branch-3.0: [fix](drop sql) add force in the tosql for
drop table and drop database #43227 (#44447)
0850bf3a263 is described below
commit 0850bf3a263fb8d98f9b1aaf2d4d56ec9035dd6a
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Dec 3 21:54:19 2024 +0800
branch-3.0: [fix](drop sql) add force in the tosql for drop table and drop
database #43227 (#44447)
Cherry-picked from #43227
Co-authored-by: Vallish Pai <[email protected]>
---
.../src/main/java/org/apache/doris/analysis/DropDbStmt.java | 3 +++
.../main/java/org/apache/doris/analysis/DropTableStmt.java | 3 +++
.../test/java/org/apache/doris/analysis/DropDbStmtTest.java | 12 +++++++++++-
.../java/org/apache/doris/analysis/DropTableStmtTest.java | 5 +++--
4 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropDbStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/DropDbStmt.java
index 2715bd1f6da..47fdfdce4e2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropDbStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DropDbStmt.java
@@ -88,6 +88,9 @@ public class DropDbStmt extends DdlStmt implements
NotFallbackInParser {
public String toSql() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("DROP DATABASE
").append("`").append(dbName).append("`");
+ if (forceDrop) {
+ stringBuilder.append(" FORCE");
+ }
return stringBuilder.toString();
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropTableStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/DropTableStmt.java
index 5e06fce75ee..d6a19e81f8e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropTableStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DropTableStmt.java
@@ -100,6 +100,9 @@ public class DropTableStmt extends DdlStmt implements
NotFallbackInParser {
public String toSql() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("DROP TABLE ").append(tableName.toSql());
+ if (forceDrop) {
+ stringBuilder.append(" FORCE");
+ }
return stringBuilder.toString();
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/analysis/DropDbStmtTest.java
b/fe/fe-core/src/test/java/org/apache/doris/analysis/DropDbStmtTest.java
index 67b44adc565..f14f5113d8f 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/DropDbStmtTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/DropDbStmtTest.java
@@ -45,7 +45,7 @@ public class DropDbStmtTest {
@Test
public void testNormal() throws UserException, AnalysisException {
- DropDbStmt stmt = new DropDbStmt(false, new DbName("test", "test"),
true);
+ DropDbStmt stmt = new DropDbStmt(false, new DbName("test", "test"),
false);
stmt.analyze(analyzer);
Assert.assertEquals("test", stmt.getCtlName());
@@ -53,6 +53,16 @@ public class DropDbStmtTest {
Assert.assertEquals("DROP DATABASE `test`", stmt.toString());
}
+ @Test
+ public void testForce() throws UserException, AnalysisException {
+ DropDbStmt stmt = new DropDbStmt(false, new DbName("test", "test"),
true);
+
+ stmt.analyze(analyzer);
+ Assert.assertEquals("test", stmt.getCtlName());
+ Assert.assertEquals("test", stmt.getDbName());
+ Assert.assertEquals("DROP DATABASE `test` FORCE", stmt.toString());
+ }
+
@Test(expected = AnalysisException.class)
public void testFailed() throws UserException, AnalysisException {
DropDbStmt stmt = new DropDbStmt(false, new DbName("", ""), true);
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/analysis/DropTableStmtTest.java
b/fe/fe-core/src/test/java/org/apache/doris/analysis/DropTableStmtTest.java
index da6d5b8d4c4..437e54f58f2 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/DropTableStmtTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/DropTableStmtTest.java
@@ -72,12 +72,13 @@ public class DropTableStmtTest {
stmt.analyze(analyzer);
Assert.assertEquals("db1", stmt.getDbName());
Assert.assertEquals("table1", stmt.getTableName());
- Assert.assertEquals("DROP TABLE `db1`.`table1`", stmt.toString());
+ // one with force.
+ Assert.assertEquals("DROP TABLE `db1`.`table1` FORCE",
stmt.toString());
}
@Test
public void testDefaultNormal() throws UserException, AnalysisException {
- DropTableStmt stmt = new DropTableStmt(false, noDbTbl, true);
+ DropTableStmt stmt = new DropTableStmt(false, noDbTbl, false);
stmt.analyze(analyzer);
Assert.assertEquals("testDb", stmt.getDbName());
Assert.assertEquals("table1", stmt.getTableName());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]