gravitino.catalog.base_schema_catalog.BaseSchemaCatalog

class gravitino.catalog.base_schema_catalog.BaseSchemaCatalog(catalog_namespace: Namespace, name: str | None = None, catalog_type: Type = Type.UNSUPPORTED, provider: str | None = None, comment: str | None = None, properties: Dict[str, str] | None = None, audit: AuditDTO | None = None, rest_client: HTTPClient | None = None)

Bases: CatalogDTO, SupportsSchemas

BaseSchemaCatalog is the base abstract class for all the catalog with schema. It provides the common methods for managing schemas in a catalog. With BaseSchemaCatalog, users can list, create, load, alter and drop a schema with specified identifier.

__init__(catalog_namespace: Namespace, name: str | None = None, catalog_type: Type = Type.UNSUPPORTED, provider: str | None = None, comment: str | None = None, properties: Dict[str, str] | None = None, audit: AuditDTO | None = None, rest_client: HTTPClient | None = None)

Methods

__init__(catalog_namespace[, name, ...])

alter_schema(schema_name, *changes)

Alter the schema with specified identifier by applying the changes.

as_fileset_catalog()

Raises:

as_schemas()

Return the {@link SupportsSchemas} if the catalog supports schema operations.

as_table_catalog()

Raises:

as_topic_catalog()

Returns:

audit_info()

builder([name, catalog_type, provider, ...])

comment()

The comment of the catalog.

create_schema([schema_name, comment, properties])

Create a new schema with specified identifier, comment and metadata.

drop_schema(schema_name, cascade)

Drop the schema with specified identifier.

format_schema_request_path(ns)

list_schemas()

List all the schemas under the given catalog namespace.

load_schema(schema_name)

Load the schema with specified identifier.

name()

Returns:

properties()

The properties of the catalog.

provider()

Returns:

schema_exists(schema_name)

Check if a schema exists.

to_schema_update_request(change)

type()

Returns:

validate()

Attributes

PROPERTY_PACKAGE

A reserved property to specify the package location of the catalog.

rest_client

PROPERTY_PACKAGE = 'package'

A reserved property to specify the package location of the catalog. The “package” is a string of path to the folder where all the catalog related dependencies is located. The dependencies under the “package” will be loaded by Gravitino to create the catalog.

The property “package” is not needed if the catalog is a built-in one, Gravitino will search the proper location using “provider” to load the dependencies. Only when the folder is in different location, the “package” property is needed.

class Type(value)

Bases: Enum

The type of the catalog.

FILESET = 'fileset'

Catalog Type for Fileset System (including HDFS, S3, etc.), like path/to/file

MESSAGING = 'messaging'

Catalog Type for Message Queue, like kafka://topic

RELATIONAL = 'relational'

“Catalog Type for Relational Data Structure, like db.table, catalog.db.table.

UNSUPPORTED = 'unsupported'

Catalog Type for test only.

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

Alter the schema with specified identifier by applying the changes.

Args:

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

Raises:

NoSuchSchemaException if the schema with specified identifier does not exist.

Returns:

The altered Schema.

as_fileset_catalog() FilesetCatalog
Raises:

UnsupportedOperationException if the catalog does not support fileset operations.

Returns:

the FilesetCatalog if the catalog supports fileset operations.

as_schemas()

Return the {@link SupportsSchemas} if the catalog supports schema operations.

Raises:

UnsupportedOperationException if the catalog does not support schema operations.

Returns:

The {@link SupportsSchemas} if the catalog supports schema operations.

as_table_catalog() TableCatalog
Raises:

UnsupportedOperationException if the catalog does not support table operations.

Returns:

the {@link TableCatalog} if the catalog supports table operations.

as_topic_catalog() TopicCatalog
Returns:

the {@link TopicCatalog} if the catalog supports topic operations.

Raises:

UnsupportedOperationException if the catalog does not support topic operations.

comment() str

The comment of the catalog. Note. this method will return null if the comment is not set for this catalog.

Returns:

The provider of the catalog.

create_schema(schema_name: str | None = None, comment: str | None = None, properties: Dict[str, str] | None = None) Schema

Create a new schema with specified identifier, comment and metadata.

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 with specified namespace does not exist. SchemaAlreadyExistsException if the schema with specified identifier already exists.

Returns:

The created Schema.

drop_schema(schema_name: str, cascade: bool) bool

Drop the schema with specified identifier.

Args:

schema_name: The name of the schema. cascade: Whether to drop all the tables under the schema.

Raises:

NonEmptySchemaException if the schema is not empty and cascade is false.

Returns:

true if the schema is dropped successfully, false otherwise.

list_schemas() List[str]

List all the schemas under the given catalog namespace.

Raises:

NoSuchCatalogException if the catalog with specified namespace does not exist.

Returns:

A list of schema names under the given catalog namespace.

load_schema(schema_name: str) Schema

Load the schema with specified identifier.

Args:

schema_name: The name of the schema.

Raises:

NoSuchSchemaException if the schema with specified identifier does not exist.

Returns:

The Schema with specified identifier.

name() str
Returns:

The name of the catalog.

properties() Dict[str, str]

The properties of the catalog. Note, this method will return null if the properties are not set.

Returns:

The properties of the catalog.

provider() str
Returns:

The provider of the catalog.

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.

type() Type
Returns:

The type of the catalog.