[bugfix](external)add check of engine and catalog types for 2.1 #39343 (#39643)

bp #39343
This commit is contained in:
wuwenchi
2024-08-21 09:50:17 +08:00
committed by GitHub
parent 8a562aeb77
commit bf26f49505
3 changed files with 111 additions and 6 deletions

View File

@ -194,6 +194,21 @@ public class CreateTableInfo {
return ImmutableList.of(tableName);
}
private void checkEngineWithCatalog() {
if (engineName.equals(ENGINE_OLAP)) {
if (!ctlName.equals(InternalCatalog.INTERNAL_CATALOG_NAME)) {
throw new AnalysisException("Cannot create olap table out of internal catalog."
+ " Make sure 'engine' type is specified when use the catalog: " + ctlName);
}
}
CatalogIf catalog = Env.getCurrentEnv().getCatalogMgr().getCatalog(ctlName);
if (catalog instanceof HMSExternalCatalog && !engineName.equals(ENGINE_HIVE)) {
throw new AnalysisException("Hms type catalog can only use `hive` engine.");
} else if (catalog instanceof IcebergExternalCatalog && !engineName.equals(ENGINE_ICEBERG)) {
throw new AnalysisException("Iceberg type catalog can only use `iceberg` engine.");
}
}
/**
* analyze create table info
*/
@ -231,12 +246,7 @@ public class CreateTableInfo {
throw new AnalysisException(e.getMessage(), e);
}
if (engineName.equals(ENGINE_OLAP)) {
if (!ctlName.equals(InternalCatalog.INTERNAL_CATALOG_NAME)) {
throw new AnalysisException("Cannot create olap table out of internal catalog."
+ " Make sure 'engine' type is specified when use the catalog: " + ctlName);
}
}
checkEngineWithCatalog();
// analyze table name
if (Strings.isNullOrEmpty(dbName)) {