gravitino.api.supports_schemas.SupportsSchemas

class gravitino.api.supports_schemas.SupportsSchemas

Bases: ABC

The Catalog interface to support schema operations. If the implemented catalog has schema semantics, it should implement this interface.

__init__()

Methods

__init__()

alter_schema(schema_name, *changes)

Apply the metadata change to a schema in the catalog.

create_schema(schema_name, comment, properties)

Create a schema in the catalog.

drop_schema(schema_name, cascade)

Drop a schema from the catalog.

list_schemas()

List schemas under the entity.

load_schema(schema_name)

Load metadata properties for a schema.

schema_exists(schema_name)

Check if a schema exists.

abstract alter_schema(schema_name: str, *changes: SchemaChange) Schema

Apply the metadata change to a schema in the catalog.

Args:

schema_name: The name of the schema. changes: The metadata changes to apply.

Raises:

NoSuchSchemaException: If the schema does not exist.

Returns:

The altered schema.

abstract create_schema(schema_name: str, comment: str, properties: Dict[str, str]) Schema

Create a schema in the catalog.

Args:

schema_name: The name of the schema. comment: The comment of the schema. properties: The properties of the schema.

Raises:

NoSuchCatalogException: If the catalog does not exist. SchemaAlreadyExistsException: If the schema already exists.

Returns:

The created schema.

abstract drop_schema(schema_name: str, cascade: bool) bool

Drop a schema from the catalog. If cascade option is true, recursively drop all objects within the schema.

Args:

schema_name: The name of the schema. cascade: If true, recursively drop all objects within the schema.

Returns:

True if the schema exists and is dropped successfully, false otherwise.

Raises:

NonEmptySchemaException: If the schema is not empty and cascade is false.

abstract list_schemas() List[str]

List schemas under the entity.

If an entity such as a table, view exists, its parent schemas must also exist and must be returned by this discovery method. For example, if table a.b.t exists, this method invoked as listSchemas(a) must return [b] in the result array

Raises:

NoSuchCatalogException: If the catalog does not exist.

Returns:

A list of schema names under the namespace.

abstract load_schema(schema_name: str) Schema

Load metadata properties for a schema.

Args:

schema_name: The name of the schema.

Raises:

NoSuchSchemaException: If the schema does not exist (optional).

Returns:

A schema.

schema_exists(schema_name: str) bool

Check if a schema exists.

If an entity such as a table, view exists, its parent namespaces must also exist. For example, if table a.b.t exists, this method invoked as schema_exists(a.b) must return true.

Args:

schema_name: The name of the schema.

Returns:

True if the schema exists, false otherwise.