Package org.apache.gravitino
Interface SupportsCatalogs
- All Known Implementing Classes:
GravitinoClient
,GravitinoMetalake
Client interface for supporting catalogs. It includes methods for listing, loading, creating,
altering and dropping catalogs.
-
Method Summary
Modifier and TypeMethodDescriptionalterCatalog
(String catalogName, CatalogChange... changes) Alter a catalog with specified catalog name and changes.default boolean
catalogExists
(String catalogName) Check if a catalog exists.createCatalog
(String catalogName, Catalog.Type type, String provider, String comment, Map<String, String> properties) Create a catalog with specified catalog name, type, provider, comment, and properties.default Catalog
createCatalog
(String catalogName, Catalog.Type type, String comment, Map<String, String> properties) Create a managed catalog with specified catalog name, type, comment, and properties.void
disableCatalog
(String catalogName) Disable a catalog.default boolean
dropCatalog
(String catalogName) Drop a catalog with specified name.boolean
dropCatalog
(String catalogName, boolean force) Drop a catalog with specified name.void
enableCatalog
(String catalogName) Enable a catalog.String[]
List the name of all catalogs in the metalake.Catalog[]
List all catalogs with their information in the metalake.loadCatalog
(String catalogName) Load a catalog by its name.void
testConnection
(String catalogName, Catalog.Type type, String provider, String comment, Map<String, String> properties) Test whether the catalog with specified parameters can be connected to before creating it.
-
Method Details
-
listCatalogs
List the name of all catalogs in the metalake.- Returns:
- The list of catalog's names.
- Throws:
NoSuchMetalakeException
- If the metalake does not exist.
-
listCatalogsInfo
List all catalogs with their information in the metalake.- Returns:
- The list of catalog's information.
- Throws:
NoSuchMetalakeException
- If the metalake with namespace does not exist.
-
loadCatalog
Load a catalog by its name.- Parameters:
catalogName
- the name of the catalog.- Returns:
- The catalog.
- Throws:
NoSuchCatalogException
- If the catalog does not exist.
-
catalogExists
Check if a catalog exists.- Parameters:
catalogName
- The name of the catalog.- Returns:
- True if the catalog exists, false otherwise.
-
createCatalog
Catalog createCatalog(String catalogName, Catalog.Type type, String provider, String comment, Map<String, String> properties) throws NoSuchMetalakeException, CatalogAlreadyExistsExceptionCreate a catalog with specified catalog name, type, provider, comment, and properties.The parameter "provider" is a short name of the catalog, used to tell Gravitino which catalog should be created. The short name:
1) should be the same as the
CatalogProvider
interface provided. 2) can be "null" if the created catalog is the managed catalog, like model, fileset catalog. For the details of the provider definition, seeCatalogProvider
.- Parameters:
catalogName
- the name of the catalog.type
- the type of the catalog.provider
- the provider of the catalog, or null if the catalog is a managed catalog.comment
- the comment of the catalog.properties
- the properties of the catalog.- Returns:
- The created catalog.
- Throws:
NoSuchMetalakeException
- If the metalake does not exist.CatalogAlreadyExistsException
- If the catalog already exists.
-
createCatalog
default Catalog createCatalog(String catalogName, Catalog.Type type, String comment, Map<String, String> properties) throws NoSuchMetalakeException, CatalogAlreadyExistsExceptionCreate a managed catalog with specified catalog name, type, comment, and properties.- Parameters:
catalogName
- the name of the catalog.type
- the type of the catalog.comment
- the comment of the catalog.properties
- the properties of the catalog.- Returns:
- The created catalog.
- Throws:
NoSuchMetalakeException
- If the metalake does not exist.CatalogAlreadyExistsException
- If the catalog already exists.
-
alterCatalog
Catalog alterCatalog(String catalogName, CatalogChange... changes) throws NoSuchCatalogException, IllegalArgumentException Alter a catalog with specified catalog name and changes.- Parameters:
catalogName
- the name of the catalog.changes
- the changes to apply to the catalog.- Returns:
- The altered catalog.
- Throws:
NoSuchCatalogException
- If the catalog does not exist.IllegalArgumentException
- If the changes cannot be applied to the catalog.
-
dropCatalog
default boolean dropCatalog(String catalogName) throws NonEmptyEntityException, CatalogInUseException Drop a catalog with specified name. Please make sure:- There is no schema in the catalog. Otherwise, a
NonEmptyEntityException
will be thrown. - The method
disableCatalog(String)
has been called before dropping the catalog. Otherwise, aCatalogInUseException
will be thrown.
dropCatalog(ident, false)
.- Parameters:
catalogName
- the name of the catalog.- Returns:
- True if the catalog was dropped, false if the catalog does not exist.
- Throws:
NonEmptyEntityException
- If the catalog is not empty.CatalogInUseException
- If the catalog is in use.
- There is no schema in the catalog. Otherwise, a
-
dropCatalog
boolean dropCatalog(String catalogName, boolean force) throws NonEmptyEntityException, CatalogInUseException Drop a catalog with specified name. If the force flag is true, it will:- Cascade drop all sub-entities (schemas, tables, etc.) of the catalog in Gravitino store.
- Drop the catalog even if it is in use.
- External resources (e.g. database, table, etc.) associated with sub-entities will not be dropped unless it is managed (such as managed fileset).
dropCatalog(String)
.- Parameters:
catalogName
- The identifier of the catalog.force
- Whether to force the drop.- Returns:
- True if the catalog was dropped, false if the catalog does not exist.
- Throws:
NonEmptyEntityException
- If the catalog is not empty and force is false.CatalogInUseException
- If the catalog is in use and force is false.
-
enableCatalog
Enable a catalog. If the catalog is already enabled, this method does nothing.- Parameters:
catalogName
- The identifier of the catalog.- Throws:
NoSuchCatalogException
- If the catalog does not exist.
-
disableCatalog
Disable a catalog. If the catalog is already disabled, this method does nothing. Once a catalog is disabled:- It can only be listed, loaded, dropped, or disable.
- Any other operations on the catalog will throw an
CatalogNotInUseException
. - Any operation on the sub-entities (schemas, tables, etc.) will throw an
CatalogNotInUseException
.
- Parameters:
catalogName
- The identifier of the catalog.- Throws:
NoSuchCatalogException
- If the catalog does not exist.
-
testConnection
void testConnection(String catalogName, Catalog.Type type, String provider, String comment, Map<String, String> properties) throws ExceptionTest whether the catalog with specified parameters can be connected to before creating it.- Parameters:
catalogName
- the name of the catalog.type
- the type of the catalog.provider
- the provider of the catalog.comment
- the comment of the catalog.properties
- the properties of the catalog.- Throws:
Exception
- if the test failed.
-