Skip to content

Commit

Permalink
branch-3.0: [fix](iceberg)Fill in the detailed error information #45285
Browse files Browse the repository at this point in the history
… (#45337)

Cherry-picked from #45285

Co-authored-by: wuwenchi <[email protected]>
  • Loading branch information
github-actions[bot] and wuwenchi authored Dec 15, 2024
1 parent 9edea93 commit a44d897
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ public void dropDb(DropDbStmt stmt) throws DdlException {
return null;
});
} catch (Exception e) {
throw new DdlException("Failed to drop database: " + stmt.getDbName() + " ,error message is: ", e);
throw new DdlException(
"Failed to drop database: " + stmt.getDbName() + ", error message is: " + e.getMessage(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.apache.doris.analysis.CreateDbStmt;
import org.apache.doris.analysis.CreateTableStmt;
import org.apache.doris.analysis.DbName;
import org.apache.doris.analysis.DropDbStmt;
import org.apache.doris.common.DdlException;
import org.apache.doris.common.UserException;
import org.apache.doris.datasource.CatalogFactory;
import org.apache.doris.nereids.parser.NereidsParser;
Expand Down Expand Up @@ -201,4 +203,28 @@ public String getTableName() {
String s = "test_tb_" + UUID.randomUUID();
return s.replaceAll("-", "");
}

@Test
public void testDropDB() {
String dbName = "db_to_delete";
CreateDbStmt createDBStmt = new CreateDbStmt(false, new DbName("iceberg", dbName), new HashMap<>());
DropDbStmt dropDbStmt = new DropDbStmt(false, new DbName("iceberg", dbName), false);
DropDbStmt dropDbStmt2 = new DropDbStmt(false, new DbName("iceberg", "not_exists"), false);
try {
// create db success
ops.createDb(createDBStmt);
// drop db success
ops.dropDb(dropDbStmt);
} catch (Throwable t) {
Assert.fail();
}

try {
ops.dropDb(dropDbStmt2);
Assert.fail();
} catch (Throwable t) {
Assert.assertTrue(t instanceof DdlException);
Assert.assertTrue(t.getMessage().contains("database doesn't exist"));
}
}
}

0 comments on commit a44d897

Please sign in to comment.