jngli commented on code in PR #14862:
URL: https://github.com/apache/gravitino/pull/14862#discussion_r4581335041
##########
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)) {
+ throw new SchemaAlreadyExistsException("Schema %s already exists",
ident);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to check if schema " + ident + "
exists", e);
+ }
+
+ String location =
+ ((SupportsSchemaLocations) provider)
+ .provisionSchemaLocation(
+ SchemaLocationContext.builder()
+ .withSchemaIdentifier(ident)
+ .withSchemaProperties(properties)
+ .withCatalogProperties(catalogProperties)
+ .build());
+ Map<String, String> schemaProperties = properties;
+ if (location != null) {
Review Comment:
Say provisionSchemaLocation is a no-op, can we relax it to return null or
empty string? If so, we can update the condition check to
StringUtils.isNotBlank(location) and remove the following precondition check
##########
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:
Remove this check which should be covered in provisionSchemaLocation as well
as schemaOps.createSchema
##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/GenericCatalogOperations.java:
##########
@@ -370,9 +448,15 @@ private boolean dropOrPurgeTable(NameIdentifier ident,
boolean purge) {
* @param ident the identifier of the table to drop
* @param purge whether to purge the table instead of dropping it
* @param schema the table's parent schema
+ * @param tablesWithRetainedData if not null, receives the identifier of the
table when it is
+ * dropped without its data being deleted
* @return true if the table was dropped, false if it did not exist
*/
- private boolean dropOrPurgeTable(NameIdentifier ident, boolean purge, Schema
schema) {
+ private boolean dropOrPurgeTable(
+ NameIdentifier ident,
+ boolean purge,
+ Schema schema,
+ @Nullable List<NameIdentifier> tablesWithRetainedData) {
Review Comment:
As commented in another file, should we only unprovision a schema when all
tables under this schema have location released?
##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/SupportsSchemaLocations.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.catalog.lakehouse.generic;
+
+import javax.annotation.Nullable;
+
+/**
+ * An optional capability of a {@link TableLocationProvider}: allocating the
location of a schema
+ * when it is created, and releasing it when the schema is dropped.
+ *
+ * <p>A provider opts in by implementing this interface alongside {@link
TableLocationProvider}.
+ * Services that allocate storage usually do so hierarchically -- a schema is
registered first, with
+ * the owner and the storage domain it belongs to, and the paths of its tables
are derived from it
+ * -- and the table callbacks alone offer no point at which to register the
schema.
+ *
+ * <p>A provider that does not implement it is never consulted for schemas,
and the catalog does no
+ * extra work on its behalf: dropping an empty schema still does not read the
schema. That is why
+ * this is a separate interface rather than default methods on {@link
TableLocationProvider}.
+ *
+ * <p>The division of responsibilities is the one {@link
TableLocationProvider} describes. The
+ * provider owns what it brought into being so that the schema location can be
used -- its
+ * registration, its quota, any container it created -- and the table formats
own the data written
+ * under it. Like the table callbacks, both methods here are called
concurrently and must be
+ * thread-safe, and the catalog applies no timeout to them.
+ *
+ * <p><b>Known limitations.</b>
+ *
+ * <ul>
+ * <li>{@link #provisionSchemaLocation(SchemaLocationContext)} is called
before the schema is
+ * stored. A creation that fails afterwards -- a schema of the same name
created concurrently,
+ * or a store failure -- leaves a location provisioned for a schema that
does not exist, and
+ * there is no compensating unprovision. A provider that answers
idempotently may have
+ * returned the allocation of the schema that won the race, and
releasing it would take it
+ * from a schema that exists. A schema that already exists is detected
before the provider is
+ * consulted, so the cases that remain are the races.
+ * <li>{@code location} is a schema property, and altering it does not tell
the provider.
+ * <li>{@link #unprovisionSchemaLocation(SchemaLocationContext)} is called
before the schema is
+ * removed. A removal that fails afterwards, or a server that stops in
between, leaves the
+ * schema in place with its location already released; dropping it again
calls the provider
+ * again for the same schema.
+ * </ul>
+ */
+public interface SupportsSchemaLocations {
+
+ /**
+ * Provisions the location of the schema that is being created.
+ *
+ * <p>The context carries the properties of the creation request, including
a caller-supplied
+ * {@code location}, if any. As with tables, what happens to a supplied
location is the provider's
+ * decision: return null to keep it, return something else to place the
schema elsewhere, or throw
+ * to refuse the creation.
+ *
+ * <p>A non-null result is stored verbatim as the schema's {@code location}
property. It must not
+ * be blank; the catalog rejects the creation with an {@link
IllegalArgumentException} otherwise.
+ * Because the built-in provider derives the location of a table from its
schema's {@code
+ * location}, recording it also keeps the schema consistent with the tables
placed under it.
+ *
+ * <p>If this method throws, the schema is not created.
+ *
+ * @param context the schema being created, with the properties of the
creation request
+ * @return the location to store on the schema, or null to keep the
properties of the request
+ * unchanged
+ */
+ @Nullable
+ String provisionSchemaLocation(SchemaLocationContext context);
Review Comment:
Add the following throws:
throws SchemaAlreadyExistsException
##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/SupportsSchemaLocations.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.catalog.lakehouse.generic;
+
+import javax.annotation.Nullable;
+
+/**
+ * An optional capability of a {@link TableLocationProvider}: allocating the
location of a schema
+ * when it is created, and releasing it when the schema is dropped.
+ *
+ * <p>A provider opts in by implementing this interface alongside {@link
TableLocationProvider}.
+ * Services that allocate storage usually do so hierarchically -- a schema is
registered first, with
+ * the owner and the storage domain it belongs to, and the paths of its tables
are derived from it
+ * -- and the table callbacks alone offer no point at which to register the
schema.
+ *
+ * <p>A provider that does not implement it is never consulted for schemas,
and the catalog does no
+ * extra work on its behalf: dropping an empty schema still does not read the
schema. That is why
+ * this is a separate interface rather than default methods on {@link
TableLocationProvider}.
+ *
+ * <p>The division of responsibilities is the one {@link
TableLocationProvider} describes. The
+ * provider owns what it brought into being so that the schema location can be
used -- its
+ * registration, its quota, any container it created -- and the table formats
own the data written
+ * under it. Like the table callbacks, both methods here are called
concurrently and must be
+ * thread-safe, and the catalog applies no timeout to them.
+ *
+ * <p><b>Known limitations.</b>
+ *
+ * <ul>
+ * <li>{@link #provisionSchemaLocation(SchemaLocationContext)} is called
before the schema is
+ * stored. A creation that fails afterwards -- a schema of the same name
created concurrently,
+ * or a store failure -- leaves a location provisioned for a schema that
does not exist, and
+ * there is no compensating unprovision. A provider that answers
idempotently may have
+ * returned the allocation of the schema that won the race, and
releasing it would take it
+ * from a schema that exists. A schema that already exists is detected
before the provider is
+ * consulted, so the cases that remain are the races.
+ * <li>{@code location} is a schema property, and altering it does not tell
the provider.
+ * <li>{@link #unprovisionSchemaLocation(SchemaLocationContext)} is called
after the schema is
+ * removed, and not at all if the server stops in between, so a provider
reclaiming real
+ * storage needs its own reconciliation against the catalog.
+ * </ul>
+ */
+public interface SupportsSchemaLocations {
+
+ /**
+ * Provisions the location of the schema that is being created.
+ *
+ * <p>The context carries the properties of the creation request, including
a caller-supplied
+ * {@code location}, if any. As with tables, what happens to a supplied
location is the provider's
+ * decision: return null to keep it, return something else to place the
schema elsewhere, or throw
+ * to refuse the creation.
+ *
+ * <p>A non-null result is stored verbatim as the schema's {@code location}
property. It must not
+ * be blank; the catalog rejects the creation with an {@link
IllegalArgumentException} otherwise.
+ * Because the built-in provider derives the location of a table from its
schema's {@code
+ * location}, recording it also keeps the schema consistent with the tables
placed under it.
+ *
+ * <p>If this method throws, the schema is not created.
+ *
+ * @param context the schema being created, with the properties of the
creation request
+ * @return the location to store on the schema, or null to keep the
properties of the request
+ * unchanged
+ */
+ @Nullable
+ String provisionSchemaLocation(SchemaLocationContext context);
Review Comment:
The interface of TableLocationProvider is introduced with Uber specific use
case, no other usage yet in the open source. Considering location provider can
be for table and/or scheme, the implementation could be a no-op.
##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/SupportsSchemaLocations.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.catalog.lakehouse.generic;
+
+import javax.annotation.Nullable;
+
+/**
+ * An optional capability of a {@link TableLocationProvider}: allocating the
location of a schema
+ * when it is created, and releasing it when the schema is dropped.
+ *
+ * <p>A provider opts in by implementing this interface alongside {@link
TableLocationProvider}.
+ * Services that allocate storage usually do so hierarchically -- a schema is
registered first, with
+ * the owner and the storage domain it belongs to, and the paths of its tables
are derived from it
+ * -- and the table callbacks alone offer no point at which to register the
schema.
+ *
+ * <p>A provider that does not implement it is never consulted for schemas,
and the catalog does no
+ * extra work on its behalf: dropping an empty schema still does not read the
schema. That is why
+ * this is a separate interface rather than default methods on {@link
TableLocationProvider}.
+ *
+ * <p>The division of responsibilities is the one {@link
TableLocationProvider} describes. The
+ * provider owns what it brought into being so that the schema location can be
used -- its
+ * registration, its quota, any container it created -- and the table formats
own the data written
+ * under it. Like the table callbacks, both methods here are called
concurrently and must be
+ * thread-safe, and the catalog applies no timeout to them.
+ *
+ * <p><b>Known limitations.</b>
+ *
+ * <ul>
+ * <li>{@link #provisionSchemaLocation(SchemaLocationContext)} is called
before the schema is
+ * stored. A creation that fails afterwards -- a schema of the same name
created concurrently,
+ * or a store failure -- leaves a location provisioned for a schema that
does not exist, and
+ * there is no compensating unprovision. A provider that answers
idempotently may have
+ * returned the allocation of the schema that won the race, and
releasing it would take it
+ * from a schema that exists. A schema that already exists is detected
before the provider is
+ * consulted, so the cases that remain are the races.
+ * <li>{@code location} is a schema property, and altering it does not tell
the provider.
+ * <li>{@link #unprovisionSchemaLocation(SchemaLocationContext)} is called
before the schema is
+ * removed. A removal that fails afterwards, or a server that stops in
between, leaves the
+ * schema in place with its location already released; dropping it again
calls the provider
+ * again for the same schema.
+ * </ul>
+ */
+public interface SupportsSchemaLocations {
+
+ /**
+ * Provisions the location of the schema that is being created.
+ *
+ * <p>The context carries the properties of the creation request, including
a caller-supplied
+ * {@code location}, if any. As with tables, what happens to a supplied
location is the provider's
+ * decision: return null to keep it, return something else to place the
schema elsewhere, or throw
+ * to refuse the creation.
+ *
+ * <p>A non-null result is stored verbatim as the schema's {@code location}
property. It must not
+ * be blank; the catalog rejects the creation with an {@link
IllegalArgumentException} otherwise.
+ * Because the built-in provider derives the location of a table from its
schema's {@code
+ * location}, recording it also keeps the schema consistent with the tables
placed under it.
+ *
+ * <p>If this method throws, the schema is not created.
+ *
+ * @param context the schema being created, with the properties of the
creation request
+ * @return the location to store on the schema, or null to keep the
properties of the request
Review Comment:
>null to keep the properties of the request
What does it mean?
##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/GenericCatalogOperations.java:
##########
@@ -218,19 +275,40 @@ public boolean dropSchema(NameIdentifier ident, boolean
cascade) throws NonEmpty
"Schema %s is not empty, cannot drop it without cascade", ident);
}
+ TableLocationProvider provider = tableLocationProvider;
+ boolean schemaHooks = provider instanceof SupportsSchemaLocations;
+ Schema schema = null;
+ if (schemaHooks || tableIdents.length > 0) {
+ try {
+ schema = loadSchema(ident);
+ } catch (NoSuchSchemaException e) {
+ return false;
+ }
+ }
+
// Drop all tables under the schema first if cascade is true. This goes
through the same path
// as the catalog level dropTable, so that the location of each table is
unprovisioned and its
// cached format invalidated. The schema is resolved once for the whole
cascade rather than
// once per table: every table here has the same parent, and the provider
may not ask for it at
// all.
- if (tableIdents.length > 0) {
- Schema cascadedSchema = loadSchema(ident);
- for (NameIdentifier tableIdent : tableIdents) {
- dropOrPurgeTable(tableIdent, false /* purge */, cascadedSchema);
- }
+ List<NameIdentifier> tablesWithRetainedData = Lists.newArrayList();
+ for (NameIdentifier tableIdent : tableIdents) {
+ dropOrPurgeTable(tableIdent, false /* purge */, schema,
tablesWithRetainedData);
}
- return schemaOps.dropSchema(ident, cascade);
+ boolean dropped = schemaOps.dropSchema(ident, cascade);
+ if (dropped && schemaHooks) {
+ unprovisionSchemaLocation(
Review Comment:
For unprovision table, let's change it as well.
##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/SupportsSchemaLocations.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.catalog.lakehouse.generic;
+
+import javax.annotation.Nullable;
+
+/**
+ * An optional capability of a {@link TableLocationProvider}: allocating the
location of a schema
+ * when it is created, and releasing it when the schema is dropped.
+ *
+ * <p>A provider opts in by implementing this interface alongside {@link
TableLocationProvider}.
+ * Services that allocate storage usually do so hierarchically -- a schema is
registered first, with
+ * the owner and the storage domain it belongs to, and the paths of its tables
are derived from it
+ * -- and the table callbacks alone offer no point at which to register the
schema.
+ *
+ * <p>A provider that does not implement it is never consulted for schemas,
and the catalog does no
+ * extra work on its behalf: dropping an empty schema still does not read the
schema. That is why
+ * this is a separate interface rather than default methods on {@link
TableLocationProvider}.
+ *
+ * <p>The division of responsibilities is the one {@link
TableLocationProvider} describes. The
+ * provider owns what it brought into being so that the schema location can be
used -- its
+ * registration, its quota, any container it created -- and the table formats
own the data written
+ * under it. Like the table callbacks, both methods here are called
concurrently and must be
+ * thread-safe, and the catalog applies no timeout to them.
+ *
+ * <p><b>Known limitations.</b>
+ *
+ * <ul>
+ * <li>{@link #provisionSchemaLocation(SchemaLocationContext)} is called
before the schema is
+ * stored. A creation that fails afterwards -- a schema of the same name
created concurrently,
+ * or a store failure -- leaves a location provisioned for a schema that
does not exist, and
+ * there is no compensating unprovision. A provider that answers
idempotently may have
+ * returned the allocation of the schema that won the race, and
releasing it would take it
+ * from a schema that exists. A schema that already exists is detected
before the provider is
+ * consulted, so the cases that remain are the races.
+ * <li>{@code location} is a schema property, and altering it does not tell
the provider.
+ * <li>{@link #unprovisionSchemaLocation(SchemaLocationContext)} is called
before the schema is
+ * removed. A removal that fails afterwards, or a server that stops in
between, leaves the
+ * schema in place with its location already released; dropping it again
calls the provider
+ * again for the same schema.
+ * </ul>
+ */
+public interface SupportsSchemaLocations {
+
+ /**
+ * Provisions the location of the schema that is being created.
+ *
+ * <p>The context carries the properties of the creation request, including
a caller-supplied
+ * {@code location}, if any. As with tables, what happens to a supplied
location is the provider's
+ * decision: return null to keep it, return something else to place the
schema elsewhere, or throw
+ * to refuse the creation.
+ *
+ * <p>A non-null result is stored verbatim as the schema's {@code location}
property. It must not
+ * be blank; the catalog rejects the creation with an {@link
IllegalArgumentException} otherwise.
+ * Because the built-in provider derives the location of a table from its
schema's {@code
+ * location}, recording it also keeps the schema consistent with the tables
placed under it.
+ *
+ * <p>If this method throws, the schema is not created.
+ *
+ * @param context the schema being created, with the properties of the
creation request
+ * @return the location to store on the schema, or null to keep the
properties of the request
+ * unchanged
+ */
+ @Nullable
+ String provisionSchemaLocation(SchemaLocationContext context);
+
+ /**
+ * Releases what this provider allocated for a schema that is being dropped.
+ *
+ * <p>It is called after the tables of the schema are dropped and before the
schema itself is
+ * removed. With cascade, the tables go through the same path as a single
table drop, so their
+ * {@link
TableLocationProvider#unprovisionTableLocation(TableLocationContext)} callbacks
have
+ * already run. The context carries the stored properties of the schema and
which of the cascaded
+ * tables kept their data.
+ *
+ * <p><b>The catalog reports; the provider decides.</b> A table that kept
its data is an external
+ * table that was dropped rather than purged: the table format left its
dataset in place and its
+ * location was deliberately not unprovisioned. When the context lists any,
the schema location
+ * may still hold data, and the provider decides whether to release it
anyway, keep it, or keep it
+ * and report it. There is deliberately no force option on the drop: the
decision belongs to the
+ * provider, as it does for tables.
+ *
+ * <p>What the provider must not touch is the same as for tables: the data.
It may remove a
+ * container it created itself only once that container holds nothing but
what the provider put
+ * there.
+ *
+ * <p>If this method throws, the drop fails and the schema stays in place,
so the drop can be
+ * retried; tables the cascade already dropped stay dropped. Because the
schema is removed only
+ * after this method returns, a retry can call it again for a schema whose
location it already
+ * released, so it must be idempotent.
+ *
+ * @param context the schema being dropped and the tables its cascade
dropped without their data
+ */
+ void unprovisionSchemaLocation(SchemaLocationContext context);
Review Comment:
```suggestion
boolean unprovisionSchemaLocation(SchemaLocationContext context);
```
Return false if the schema no longer exists to ensure idempotency across
multiple calls.
##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/SchemaLocationContext.java:
##########
@@ -0,0 +1,235 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.catalog.lakehouse.generic;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.apache.gravitino.NameIdentifier;
+
+/**
+ * The context passed to a {@link SupportsSchemaLocations} provider on both of
its callbacks: when a
+ * schema is being created, and when a schema has been dropped.
+ *
+ * <p>As with {@link TableLocationContext}, one type serves both callbacks so
that a new input
+ * becomes an additional accessor rather than a signature change. Build
instances through {@link
+ * #builder()}.
+ */
+public class SchemaLocationContext {
+
+ private final NameIdentifier schemaIdentifier;
+
+ private final Map<String, String> schemaProperties;
+
+ private final Map<String, String> catalogProperties;
+
+ private final boolean cascade;
+
+ private final List<NameIdentifier> tablesWithRetainedData;
Review Comment:
Should we only unprovision a schema only when it's empty, i.e, no tables
exist in this schema?
##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/SchemaLocationContext.java:
##########
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.catalog.lakehouse.generic;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.apache.gravitino.NameIdentifier;
+
+/**
+ * The context passed to a {@link SupportsSchemaLocations} provider on both of
its callbacks: when a
+ * schema is being created, and when a schema is being dropped.
+ *
+ * <p>As with {@link TableLocationContext}, one type serves both callbacks so
that a new input
+ * becomes an additional accessor rather than a signature change. Build
instances through {@link
+ * #builder()}.
+ */
+public class SchemaLocationContext {
+
+ private final NameIdentifier schemaIdentifier;
+
+ private final Map<String, String> schemaProperties;
+
+ private final Map<String, String> catalogProperties;
Review Comment:
What's the usage of catalog properties?
--
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]