xiaozcy commented on code in PR #7622: URL: https://github.com/apache/gravitino/pull/7622#discussion_r2212470995
########## catalogs/catalog-model/src/main/java/org/apache/gravitino/catalog/model/ModelCatalogOperations.java: ########## @@ -524,6 +557,48 @@ private ModelVersion internalGetModelVersion(NameIdentifier ident) { } } + private String internalGetModelVersionUri( + NameIdentifier modelIdent, NameIdentifier modelVersionIdent, String uriName) { + ModelVersion modelVersion = internalGetModelVersion(modelVersionIdent); + + Map<String, String> uris = modelVersion.uris(); + // If the uriName is not null, get from the uris directly + if (uriName != null) { + return getUriByName(uris, uriName, modelVersionIdent); + } + + // If there is only one uri of the model version, use it + if (uris.size() == 1) { + return uris.values().iterator().next(); + } + + // If the uri name is null, try to get the default uri name from the model version properties + Map<String, String> modelVersionProperties = modelVersion.properties(); + if (modelVersionProperties.containsKey(ModelVersion.PROPERTY_DEFAULT_URI_NAME)) { + String defaultUriName = modelVersionProperties.get(ModelVersion.PROPERTY_DEFAULT_URI_NAME); + return getUriByName(uris, defaultUriName, modelVersionIdent); + } + + // If the default uri name is not set for the model version, try to get the default uri name + // from the model properties + Map<String, String> modelProperties = getModel(modelIdent).properties(); + if (modelProperties.containsKey(ModelVersion.PROPERTY_DEFAULT_URI_NAME)) { + String defaultUriName = modelProperties.get(ModelVersion.PROPERTY_DEFAULT_URI_NAME); + return getUriByName(uris, defaultUriName, modelVersionIdent); + } + + throw new IllegalArgumentException("Either uri name of default uri name should be provided"); Review Comment: The exception here will only be thrown when the uri name is not specified, how about change the message to "The default uri name needs to be set when the uri name is not specified"? -- 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...@gravitino.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org