morningman commented on code in PR #20137: URL: https://github.com/apache/doris/pull/20137#discussion_r1209258543
########## fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogFactory.java: ########## @@ -74,21 +71,33 @@ public static CatalogLog constructorCatalogLog(long catalogId, StatementBase stm /** * create the catalog instance from catalog log. */ - public static CatalogIf constructorFromLog(CatalogLog log) throws DdlException { - return constructorCatalog(log.getCatalogId(), log.getCatalogName(), log.getResource(), - log.getComment(), log.getProps()); + public static CatalogIf createFromLog(CatalogLog log) throws DdlException { + return createCatalog(log.getCatalogId(), log.getCatalogName(), log.getResource(), + log.getComment(), log.getProps(), true); } - private static CatalogIf constructorCatalog(long catalogId, String name, String resource, String comment, - Map<String, String> props) throws DdlException { + /** + * create the catalog instance from creating statement. + */ + public static CatalogIf createFromStmt(long catalogId, CreateCatalogStmt stmt) + throws DdlException { + return createCatalog(catalogId, stmt.getCatalogName(), stmt.getResource(), + stmt.getComment(), stmt.getProperties(), false); + } + + private static CatalogIf createCatalog(long catalogId, String name, String resource, String comment, + Map<String, String> props, boolean isReplay) throws DdlException { // get catalog type from resource or properties String catalogType; if (!Strings.isNullOrEmpty(resource)) { - Resource catalogResource = Optional.ofNullable(Env.getCurrentEnv().getResourceMgr().getResource(resource)) - .orElseThrow(() -> new DdlException("Resource doesn't exist: " + resource)); - catalogType = catalogResource.getType().name().toLowerCase(); - if (props.containsKey(CatalogMgr.CATALOG_TYPE_PROP)) { - throw new DdlException("Can not set 'type' when creating catalog with resource"); + Resource catalogResource = Env.getCurrentEnv().getResourceMgr().getResource(resource); + if (catalogResource == null) { Review Comment: Yes, this is a bug, i don't know the reason, but it worth nothing to fix it because i decide to forbid creating catalog with resource. This operation makes things complex and hard to keep meta data consistency. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org