anilkumgopalap commented on code in PR #14862:
URL: https://github.com/apache/gravitino/pull/14862#discussion_r4603237931


##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/GenericCatalogOperations.java:
##########
@@ -169,10 +172,56 @@ public NameIdentifier[] listSchemas(Namespace namespace) 
throws NoSuchCatalogExc
     return schemaOps.listSchemas(namespace);
   }
 
+  /**
+   * Creates a schema, asking the {@link TableLocationProvider} for its 
location first when the
+   * provider implements {@link SupportsSchemaLocations}.
+   *
+   * <p>A schema that already exists is rejected before the provider is 
consulted, so that a
+   * provider is never asked to allocate for a name that is taken. A provider 
that throws fails the
+   * creation, and a non-null location it returns is stored as the schema's 
{@code location}.
+   *
+   * @param ident the identifier of the schema to create
+   * @param comment the comment of the schema
+   * @param properties the properties of the schema
+   * @return the created schema
+   * @throws NoSuchCatalogException if the catalog does not exist
+   * @throws SchemaAlreadyExistsException if the schema already exists
+   */
   @Override
   public Schema createSchema(NameIdentifier ident, String comment, Map<String, 
String> properties)
       throws NoSuchCatalogException, SchemaAlreadyExistsException {
-    return schemaOps.createSchema(ident, comment, properties);
+    TableLocationProvider provider = tableLocationProvider;
+    if (!(provider instanceof SupportsSchemaLocations)) {
+      return schemaOps.createSchema(ident, comment, properties);
+    }
+
+    try {
+      if (store.exists(ident, SCHEMA)) {

Review Comment:
   Done. A duplicate is now rejected by `schemaOps.createSchema` (or by the 
provider itself), and the existing schema keeps its location; there's a test 
for that.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to