diff --git a/fe/fe-core/src/main/java/com/starrocks/connector/hive/HiveMetadata.java b/fe/fe-core/src/main/java/com/starrocks/connector/hive/HiveMetadata.java index 9c640e016642a..04d863d7d6411 100644 --- a/fe/fe-core/src/main/java/com/starrocks/connector/hive/HiveMetadata.java +++ b/fe/fe-core/src/main/java/com/starrocks/connector/hive/HiveMetadata.java @@ -162,6 +162,7 @@ public void dropTable(DropTableStmt stmt) throws DdlException { hmsTable.getDbName(), hmsTable.getTableName(), hmsTable.getTableLocation())); } } else { +<<<<<<< HEAD if (!stmt.isForceDrop()) { throw new DdlException(String.format("Table location will be cleared." + " 'Force' must be set when dropping a hive table." + @@ -169,6 +170,14 @@ public void dropTable(DropTableStmt stmt) throws DdlException { } HiveTable hiveTable = (HiveTable) getTable(dbName, tableName); +======= + HiveTable hiveTable = null; + try { + hiveTable = (HiveTable) getTable(dbName, tableName); + } catch (Exception e) { + // ignore not found exception + } +>>>>>>> aeff4a3734 ([BugFix] Drop inexistent table silently (#50150)) if (hiveTable == null && stmt.isSetIfExists()) { LOG.warn("Table {}.{} doesn't exist", dbName, tableName); return; diff --git a/fe/fe-core/src/main/java/com/starrocks/sql/analyzer/AuthorizerStmtVisitor.java b/fe/fe-core/src/main/java/com/starrocks/sql/analyzer/AuthorizerStmtVisitor.java index 0214529cc3e1b..ed017305adc8d 100644 --- a/fe/fe-core/src/main/java/com/starrocks/sql/analyzer/AuthorizerStmtVisitor.java +++ b/fe/fe-core/src/main/java/com/starrocks/sql/analyzer/AuthorizerStmtVisitor.java @@ -200,6 +200,12 @@ import com.starrocks.sql.ast.pipe.DropPipeStmt; import com.starrocks.sql.ast.pipe.PipeName; import com.starrocks.sql.ast.pipe.ShowPipeStmt; +<<<<<<< HEAD +======= +import com.starrocks.sql.common.MetaUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +>>>>>>> aeff4a3734 ([BugFix] Drop inexistent table silently (#50150)) import java.util.List; import java.util.Map; @@ -1432,7 +1438,9 @@ public Void visitDropTableStatement(DropTableStmt statement, ConnectContext cont PrivilegeType.DROP.name(), ObjectType.VIEW.name(), statement.getTbl().getTbl()); } } else { + Table table = null; try { + table = MetaUtils.getTable(context, statement.getTbl()); Authorizer.checkTableAction(context.getCurrentUserIdentity(), context.getCurrentRoleIds(), statement.getTbl(), PrivilegeType.DROP); } catch (AccessDeniedException e) { @@ -1440,6 +1448,12 @@ public Void visitDropTableStatement(DropTableStmt statement, ConnectContext cont statement.getTbl().getCatalog(), context.getCurrentUserIdentity(), context.getCurrentRoleIds(), PrivilegeType.DROP.name(), ObjectType.TABLE.name(), statement.getTbl().getTbl()); + } catch (Exception e) { + if (table == null && statement.isSetIfExists()) { + // an exception will be thrown if table is not found, ignore it if `if exists` is set. + return null; + } + throw e; } } return null;