[fix](drop table) Improve error prompts when deleting materialized views (#35437) (#35763)

bp #35437

Co-authored-by: HB <hubiao01@corp.netease.com>
This commit is contained in:
Mingyu Chen
2024-06-01 23:48:52 +08:00
committed by GitHub
parent 2675014491
commit 75fd8c4226
3 changed files with 167 additions and 8 deletions

View File

@ -862,21 +862,21 @@ public class InternalCatalog implements CatalogIf<Database> {
if (stmt.isView()) {
if (!(table instanceof View)) {
ErrorReport.reportDdlException(ErrorCode.ERR_WRONG_OBJECT, dbName, tableName, "VIEW",
genDropHint(table));
genDropHint(dbName, table));
}
} else {
if (table instanceof View) {
ErrorReport.reportDdlException(ErrorCode.ERR_WRONG_OBJECT, dbName, tableName, "TABLE",
genDropHint(table));
genDropHint(dbName, table));
}
}
if (!stmt.isMaterializedView() && table instanceof MTMV) {
ErrorReport.reportDdlException(ErrorCode.ERR_WRONG_OBJECT, dbName, tableName, "TABLE",
genDropHint(table));
genDropHint(dbName, table));
} else if (stmt.isMaterializedView() && !(table instanceof MTMV)) {
ErrorReport.reportDdlException(ErrorCode.ERR_WRONG_OBJECT, dbName, tableName, "MTMV",
genDropHint(table));
genDropHint(dbName, table));
}
if (!stmt.isForceDrop()) {
@ -939,16 +939,16 @@ public class InternalCatalog implements CatalogIf<Database> {
tableName, dbName, stmt.isForceDrop(), costTimes);
}
private static String genDropHint(TableIf table) {
private static String genDropHint(String dbName, TableIf table) {
String type = "";
if (table instanceof View) {
type = "VIEW";
} else if (table instanceof OlapTable) {
type = "TABLE";
} else if (table instanceof MTMV) {
type = "MATERIALIZED VIEW";
} else if (table instanceof OlapTable) {
type = "TABLE";
}
return "Use 'DROP " + type + " " + table.getName();
return String.format("Use 'DROP %s %s.%s'", type, dbName, table.getName());
}
public boolean unprotectDropTable(Database db, Table table, boolean isForceDrop, boolean isReplay,