anilkumgopalap opened a new pull request, #14862:
URL: https://github.com/apache/gravitino/pull/14862

   ### What changes were proposed in this pull request?
   Adds an opt-in `SupportsSchemaLocations` interface that a 
`TableLocationProvider` can implement to take part in the schema lifecycle of 
the lakehouse-generic catalog:
   - `provisionSchemaLocation(SchemaLocationContext)` is called by 
`createSchema` before the schema is stored. A non-null result is stored as the 
schema's `location` property; `null` keeps the request unchanged; a blank 
result is rejected; throwing refuses the creation. An existing schema is 
rejected before the provider is consulted.
   - `unprovisionSchemaLocation(SchemaLocationContext)` is called by 
`dropSchema` after the schema has been removed. With cascade, tables go through 
the usual drop path first. The context reports `tablesWithRetainedData()` 
(external tables dropped rather than purged) so the provider can decide whether 
to release the schema location. A failure is logged at WARN and the drop still 
succeeds.
   - New `SchemaLocationContext` carrying the schema identifier, schema and 
catalog properties, the cascade flag, and the retained tables.
   - Docs: new "Schema locations (optional)" section in 
`lakehouse-generic-catalog.md`.
   Providers that don't implement the interface are never consulted for 
schemas, and the catalog does no extra work for them.
   ### Why are the changes needed?
   Storage services usually allocate hierarchically: a schema (database) is 
registered first with its owner and storage domain, and table paths are derived 
from it. The table callbacks of `TableLocationProvider` (#13058) offer no point 
at which to register the schema, so such a provider can't be built today.
   Fixes #14211
   ### Does this PR introduce _any_ user-facing change?
   A new optional SPI interface, `SupportsSchemaLocations`, for 
`TableLocationProvider` implementations. No new properties; no change for 
existing providers.
   ### How was this patch tested?
   - New unit tests in `TestGenericCatalogOperations` (10) using a test 
provider, `FakeSchemaLocationProvider`, covering: allocation, null and blank 
results, refusal, existing schema, drop, drop of a missing schema, cascade with 
retained tables, unprovision failure, and a provider without schema support.
   - New `TestSchemaLocationContext` (5).
   - `./gradlew :catalogs:catalog-lakehouse-generic:test -PskipITs` and 
`spotlessCheck` pass.
   - Manually verified on a local server build with a sample provider: schema 
location allocation, refusal, duplicate create, cascade drop reporting the 
retained external table, and drop of a missing schema.
   3. Click the Preview tab to check that it renders cleanly, then click Create 
pull request.


-- 
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