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([parent_schema])

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(parent_schema: str | None = None) 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

If parent_schema is provided, list the schemas directly under the given parent schema. This is only meaningful for catalogs that support hierarchical (multi-level) schemas, such as an Iceberg catalog accessed through the Gravitino REST server with a configured schema separator. For example, when the schemas a, a:b and a:b:c exist, this method invoked with parent a:b returns [a:b:c]. For a flat catalog, or a parent schema that has no children, an empty list is returned.

Args:
parent_schema: The parent (possibly hierarchical) schema name whose direct children are

listed, e.g. "a" or "a:b". When None, all schemas under the catalog are listed. Must not be blank when provided.

Raises:

IllegalArgumentException: If parent_schema is provided but blank. NoSuchCatalogException: If the catalog does not exist. NoSuchSchemaException: If parent_schema is provided but 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.