[fix](multi-catalog) add config to disable external DDL (#31528)
from #31453
This commit is contained in:
@ -2216,6 +2216,12 @@ public class Config extends ConfigBase {
|
||||
"Sample size for hive row count estimation."})
|
||||
public static int hive_stats_partition_sample_size = 3000;
|
||||
|
||||
@ConfField(mutable = true, masterOnly = true, description = {
|
||||
"启用外表DDL",
|
||||
"Enable external table DDL"})
|
||||
public static boolean enable_external_ddl = false;
|
||||
|
||||
|
||||
@ConfField(mutable = true, masterOnly = true, description = {
|
||||
"Hive创建外部表默认指定的input format",
|
||||
"Default hive input format for creating table."})
|
||||
|
||||
@ -254,6 +254,10 @@ public class CreateTableStmt extends DdlStmt {
|
||||
return engineName;
|
||||
}
|
||||
|
||||
public String getCatalogName() {
|
||||
return tableName.getCtl();
|
||||
}
|
||||
|
||||
public String getDbName() {
|
||||
return tableName.getDb();
|
||||
}
|
||||
|
||||
@ -61,6 +61,10 @@ public class DropTableStmt extends DdlStmt {
|
||||
return tableName.getTbl();
|
||||
}
|
||||
|
||||
public String getCatalogName() {
|
||||
return tableName.getCtl();
|
||||
}
|
||||
|
||||
public boolean isView() {
|
||||
return isView;
|
||||
}
|
||||
|
||||
@ -3039,7 +3039,9 @@ public class Env {
|
||||
* 11. add this table to ColocateGroup if necessary
|
||||
*/
|
||||
public void createTable(CreateTableStmt stmt) throws UserException {
|
||||
getCurrentCatalog().createTable(stmt);
|
||||
CatalogIf<?> catalogIf = catalogMgr.getCatalogOrException(stmt.getCatalogName(),
|
||||
catalog -> new DdlException(("Unknown catalog " + catalog)));
|
||||
catalogIf.createTable(stmt);
|
||||
}
|
||||
|
||||
public void createTableLike(CreateTableLikeStmt stmt) throws DdlException {
|
||||
@ -3659,7 +3661,9 @@ public class Env {
|
||||
|
||||
// Drop table
|
||||
public void dropTable(DropTableStmt stmt) throws DdlException {
|
||||
getCurrentCatalog().dropTable(stmt);
|
||||
CatalogIf<?> catalogIf = catalogMgr.getCatalogOrException(stmt.getCatalogName(),
|
||||
catalog -> new DdlException(("Unknown catalog " + catalog)));
|
||||
catalogIf.dropTable(stmt);
|
||||
}
|
||||
|
||||
public boolean unprotectDropTable(Database db, Table table, boolean isForceDrop, boolean isReplay,
|
||||
|
||||
@ -28,6 +28,7 @@ import org.apache.doris.catalog.InfoSchemaDb;
|
||||
import org.apache.doris.catalog.Resource;
|
||||
import org.apache.doris.catalog.TableIf;
|
||||
import org.apache.doris.cluster.ClusterNamespace;
|
||||
import org.apache.doris.common.Config;
|
||||
import org.apache.doris.common.DdlException;
|
||||
import org.apache.doris.common.UserException;
|
||||
import org.apache.doris.common.io.Text;
|
||||
@ -592,9 +593,12 @@ public abstract class ExternalCatalog
|
||||
|
||||
@Override
|
||||
public void createDb(CreateDbStmt stmt) throws DdlException {
|
||||
if (!Config.enable_external_ddl) {
|
||||
throw new DdlException("Experimental. The config enable_external_ddl needs to be set to true.");
|
||||
}
|
||||
makeSureInitialized();
|
||||
if (metadataOps == null) {
|
||||
LOG.warn("dropDatabase not implemented");
|
||||
LOG.warn("createDb not implemented");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@ -607,9 +611,12 @@ public abstract class ExternalCatalog
|
||||
|
||||
@Override
|
||||
public void dropDb(DropDbStmt stmt) throws DdlException {
|
||||
if (!Config.enable_external_ddl) {
|
||||
throw new DdlException("Experimental. The config enable_external_ddl needs to be set to true.");
|
||||
}
|
||||
makeSureInitialized();
|
||||
if (metadataOps == null) {
|
||||
LOG.warn("dropDatabase not implemented");
|
||||
LOG.warn("dropDb not implemented");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@ -622,6 +629,9 @@ public abstract class ExternalCatalog
|
||||
|
||||
@Override
|
||||
public void createTable(CreateTableStmt stmt) throws UserException {
|
||||
if (!Config.enable_external_ddl) {
|
||||
throw new DdlException("Experimental. The config enable_external_ddl needs to be set to true.");
|
||||
}
|
||||
makeSureInitialized();
|
||||
if (metadataOps == null) {
|
||||
LOG.warn("createTable not implemented");
|
||||
@ -637,6 +647,9 @@ public abstract class ExternalCatalog
|
||||
|
||||
@Override
|
||||
public void dropTable(DropTableStmt stmt) throws DdlException {
|
||||
if (!Config.enable_external_ddl) {
|
||||
throw new DdlException("Experimental. The config enable_external_ddl needs to be set to true.");
|
||||
}
|
||||
makeSureInitialized();
|
||||
if (metadataOps == null) {
|
||||
LOG.warn("dropTable not implemented");
|
||||
|
||||
Reference in New Issue
Block a user