Jibing-Li commented on code in PR #20137: URL: https://github.com/apache/doris/pull/20137#discussion_r1209033286
########## 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: I can't think of a scenario how could this happen. If the resource doesn't exist, shouldn't it has already been dropped before creating the new catalog with this resource? -- 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