gravitino.api.rel.table_catalog.TableCatalog¶
- class gravitino.api.rel.table_catalog.TableCatalog¶
Bases:
ABCThe TableCatalog interface defines the public API for managing tables in a schema.
If the catalog implementation supports tables, it must implement this interface.
- __init__()¶
Methods
__init__()alter_table(identifier, *changes)Alter a table in the catalog.
create_table(identifier, columns[, comment, ...])Create a table in the catalog.
drop_table(identifier)Drop a table from the catalog.
list_tables(namespace)List the tables in a namespace from the catalog.
load_table(identifier)Load table metadata by NameIdentifier from the catalog.
purge_table(identifier)Drop a table from the catalog and completely remove its data.
table_exists(identifier)Check if a table exists using an NameIdentifier from the catalog.
- abstract alter_table(identifier: NameIdentifier, *changes) Table¶
Alter a table in the catalog.
- Args:
identifier (NameIdentifier): A table identifier. *changes:
Table changes (defined in class TableChange) to apply to the table.
- Returns:
Table: The updated table metadata.
- Raises:
- NoSuchTableException:
If the table does not exist.
- IllegalArgumentException:
If the change is rejected by the implementation.
- abstract create_table(identifier: NameIdentifier, columns: list[gravitino.api.rel.column.Column], comment: str | None = None, properties: dict[str, str] | None = None, partitioning: list[gravitino.api.rel.expressions.transforms.transform.Transform] | None = None, distribution: Distribution | None = None, sort_orders: list[gravitino.api.rel.expressions.sorts.sort_order.SortOrder] | None = None, indexes: list[gravitino.api.rel.indexes.index.Index] | None = None) Table¶
Create a table in the catalog.
- Args:
- identifier (NameIdentifier):
A table identifier.
- columns (list[Column]):
The columns of the new table.
- comment (str, optional):
The table comment. Defaults to None.
- properties (dict[str, str], optional):
The table properties. Defaults to None.
- partitioning (Optional[list[Transform]], optional):
The table partitioning. Defaults to None.
- distribution (Optional[Distribution], optional):
The distribution of the table. Defaults to None.
- sort_orders (Optional[list[SortOrder]], optional):
The sort orders of the table. Defaults to None.
- indexes (Optional[list[Index]], optional):
The table indexes. Defaults to None.
- Raises:
- NoSuchSchemaException:
If the schema does not exist.
- TableAlreadyExistsException:
If the table already exists.
- Returns:
- Table:
The created table metadata.
- abstract drop_table(identifier: NameIdentifier) bool¶
Drop a table from the catalog.
Removes both the metadata and the directory associated with the table from the file system if the table is not an external table. In case of an external table, only the associated metadata is removed.
- Args:
identifier (NameIdentifier): A table identifier.
- Returns:
bool: True if the table is dropped, False if the table does not exist.
- abstract list_tables(namespace: Namespace) list[gravitino.name_identifier.NameIdentifier]¶
List the tables in a namespace from the catalog.
- Args:
namespace (Namespace): A namespace.
- Returns:
list[NameIdentifier]: An array of table identifiers in the namespace.
- Raises:
NoSuchSchemaException: If the schema does not exist.
- abstract load_table(identifier: NameIdentifier) Table¶
Load table metadata by NameIdentifier from the catalog.
- Args:
identifier (NameIdentifier): A table identifier.
- Returns:
Table: The table metadata.
- Raises:
NoSuchTableException: If the table does not exist.
- purge_table(identifier: NameIdentifier) bool¶
Drop a table from the catalog and completely remove its data.
Removes both the metadata and the directory associated with the table completely and skipping trash. If the table is an external table or the catalogs don’t support purge table, UnsupportedOperationException is thrown. If the catalog supports to purge a table, this method should be overridden. The default implementation throws an UnsupportedOperationException.
- Args:
identifier (NameIdentifier): A table identifier.
- Raises:
UnsupportedOperationException: If the catalog does not support to purge a table.
- Returns:
bool: True if the table is purged, False if the table does not exist.
- table_exists(identifier: NameIdentifier) bool¶
Check if a table exists using an NameIdentifier from the catalog.
- Args:
identifier (NameIdentifier): A table identifier.
- Returns:
bool: True If the table exists, False otherwise.