From a44d89720943968b62b8cfcabc934c45e2ec401e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 14 Dec 2024 19:15:52 -0800 Subject: [PATCH] branch-3.0: [fix](iceberg)Fill in the detailed error information #45285 (#45337) Cherry-picked from #45285 Co-authored-by: wuwenchi --- .../iceberg/IcebergMetadataOps.java | 3 ++- .../iceberg/CreateIcebergTableTest.java | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataOps.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataOps.java index 970814b7acdc85..440a671afe58f1 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataOps.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataOps.java @@ -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); } } diff --git a/fe/fe-core/src/test/java/org/apache/doris/datasource/iceberg/CreateIcebergTableTest.java b/fe/fe-core/src/test/java/org/apache/doris/datasource/iceberg/CreateIcebergTableTest.java index 1c780d63c9cd8b..439f6f2aa7de21 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/datasource/iceberg/CreateIcebergTableTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/datasource/iceberg/CreateIcebergTableTest.java @@ -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; @@ -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")); + } + } }