Skip to content

Commit

Permalink
[fix](iceberg)Fill in the detailed error information (#45285)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

Problem Summary:

When dropping a database, fill in the detailed error information.
  • Loading branch information
wuwenchi authored and morningman committed Dec 15, 2024
1 parent 249ffa4 commit 99b7695
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 @@ -158,7 +158,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 99b7695

Please sign in to comment.