Package org.apache.gravitino.rel
Interface TableCatalog
The TableCatalog interface defines the public API for managing tables in a schema. If the catalog
implementation supports tables, it must implement this interface.
-
Method Summary
Modifier and TypeMethodDescriptionalterTable
(NameIdentifier ident, TableChange... changes) Apply thechange
to a table in the catalog.default Table
createTable
(NameIdentifier ident, Column[] columns, String comment, Map<String, String> properties) Create a table in the catalog based on the provided details.default Table
createTable
(NameIdentifier ident, Column[] columns, String comment, Map<String, String> properties, Distribution distribution) Create a table in the catalog.default Table
createTable
(NameIdentifier ident, Column[] columns, String comment, Map<String, String> properties, Distribution distribution, SortOrder[] sortOrders) Create a table in the catalog.default Table
createTable
(NameIdentifier ident, Column[] columns, String comment, Map<String, String> properties, SortOrder[] sortOrders) Create a table in the catalog.default Table
createTable
(NameIdentifier ident, Column[] columns, String comment, Map<String, String> properties, Transform[] partitions) Create a table in the catalog.default Table
createTable
(NameIdentifier ident, Column[] columns, String comment, Map<String, String> properties, Transform[] partitions, Distribution distribution, SortOrder[] sortOrders) Create a partitioned table in the catalog.createTable
(NameIdentifier ident, Column[] columns, String comment, Map<String, String> properties, Transform[] partitions, Distribution distribution, SortOrder[] sortOrders, Index[] indexes) Create a table in the catalog.boolean
dropTable
(NameIdentifier ident) Removes both the metadata and the directory associated with the table from the file system if the table is not an external table.listTables
(Namespace namespace) List the tables in a namespace from the catalog.loadTable
(NameIdentifier ident) Load table metadata byNameIdentifier
from the catalog.default boolean
purgeTable
(NameIdentifier ident) Drop a table from the catalog and completely remove its data.default boolean
tableExists
(NameIdentifier ident) Check if a table exists using anNameIdentifier
from the catalog.
-
Method Details
-
listTables
List the tables in a namespace from the catalog.- Parameters:
namespace
- A namespace.- Returns:
- An array of table identifiers in the namespace.
- Throws:
NoSuchSchemaException
- If the schema does not exist.
-
loadTable
Load table metadata byNameIdentifier
from the catalog.- Parameters:
ident
- A table identifier.- Returns:
- The table metadata.
- Throws:
NoSuchTableException
- If the table does not exist.
-
tableExists
Check if a table exists using anNameIdentifier
from the catalog.- Parameters:
ident
- A table identifier.- Returns:
- true If the table exists, false otherwise.
-
createTable
default Table createTable(NameIdentifier ident, Column[] columns, String comment, Map<String, String> properties) throws NoSuchSchemaException, TableAlreadyExistsExceptionCreate a table in the catalog based on the provided details.This method returns the table as defined by the user without applying all defaults. If you need the table with default values applied, use the
loadTable(NameIdentifier)
method after creation.- Parameters:
ident
- A table identifier.columns
- The columns of the new table.comment
- The table comment.properties
- The table properties.- Returns:
- The table as defined by the caller, without all default values.
- Throws:
NoSuchSchemaException
- If the schema does not exist.TableAlreadyExistsException
- If the table already exists.
-
createTable
default Table createTable(NameIdentifier ident, Column[] columns, String comment, Map<String, String> properties, Transform[] partitions) throws NoSuchSchemaException, TableAlreadyExistsExceptionCreate a table in the catalog.- Parameters:
ident
- A table identifier.columns
- The columns of the new table.comment
- The table comment.properties
- The table properties.partitions
- The table partitioning.- Returns:
- The created table metadata.
- Throws:
NoSuchSchemaException
- If the schema does not exist.TableAlreadyExistsException
- If the table already exists.
-
createTable
default Table createTable(NameIdentifier ident, Column[] columns, String comment, Map<String, String> properties, Distribution distribution, SortOrder[] sortOrders) throws NoSuchSchemaException, TableAlreadyExistsExceptionCreate a table in the catalog.- Parameters:
ident
- A table identifier.columns
- The columns of the new table.comment
- The table comment.properties
- The table properties.distribution
- The distribution of the tablesortOrders
- The sort orders of the table- Returns:
- The created table metadata.
- Throws:
NoSuchSchemaException
- If the schema does not exist.TableAlreadyExistsException
- If the table already exists.
-
createTable
default Table createTable(NameIdentifier ident, Column[] columns, String comment, Map<String, String> properties, Distribution distribution) throws NoSuchSchemaException, TableAlreadyExistsExceptionCreate a table in the catalog.- Parameters:
ident
- A table identifier.columns
- The columns of the new table.comment
- The table comment.properties
- The table properties.distribution
- The distribution of the table.- Returns:
- The created table metadata.
- Throws:
NoSuchSchemaException
- If the schema does not exist.TableAlreadyExistsException
- If the table already exists.
-
createTable
default Table createTable(NameIdentifier ident, Column[] columns, String comment, Map<String, String> properties, SortOrder[] sortOrders) throws NoSuchSchemaException, TableAlreadyExistsExceptionCreate a table in the catalog.- Parameters:
ident
- A table identifier.columns
- The columns of the new table.comment
- The table comment.properties
- The table properties.sortOrders
- The sort orders of the table- Returns:
- The created table metadata.
- Throws:
NoSuchSchemaException
- If the schema does not exist.TableAlreadyExistsException
- If the table already exists.
-
createTable
default Table createTable(NameIdentifier ident, Column[] columns, String comment, Map<String, String> properties, Transform[] partitions, Distribution distribution, SortOrder[] sortOrders) throws NoSuchSchemaException, TableAlreadyExistsExceptionCreate a partitioned table in the catalog.- Parameters:
ident
- A table identifier.columns
- The columns of the new table.comment
- The table comment.properties
- The table properties.distribution
- The distribution of the tablesortOrders
- The sort orders of the tablepartitions
- The table partitioning.- Returns:
- The created table metadata.
- Throws:
NoSuchSchemaException
- If the schema does not exist.TableAlreadyExistsException
- If the table already exists.
-
createTable
Table createTable(NameIdentifier ident, Column[] columns, String comment, Map<String, String> properties, Transform[] partitions, Distribution distribution, SortOrder[] sortOrders, Index[] indexes) throws NoSuchSchemaException, TableAlreadyExistsExceptionCreate a table in the catalog.- Parameters:
ident
- A table identifier.columns
- The columns of the new table.comment
- The table comment.properties
- The table properties.distribution
- The distribution of the tablesortOrders
- The sort orders of the tablepartitions
- The table partitioning.indexes
- The table indexes.- Returns:
- The created table metadata.
- Throws:
NoSuchSchemaException
- If the schema does not exist.TableAlreadyExistsException
- If the table already exists.
-
alterTable
Table alterTable(NameIdentifier ident, TableChange... changes) throws NoSuchTableException, IllegalArgumentException Apply thechange
to a table in the catalog.Implementations may reject the change. If any change is rejected, no changes should be applied to the table.
- Parameters:
ident
- A table identifier.changes
- Table changes to apply to the table.- Returns:
- The updated table metadata.
- Throws:
NoSuchTableException
- If the table does not exist.IllegalArgumentException
- If the change is rejected by the implementation.
-
dropTable
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.- Parameters:
ident
- A table identifier.- Returns:
- True if the table is dropped, false if the table does not exist.
-
purgeTable
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
.- Parameters:
ident
- A table identifier.- Returns:
- True if the table is purged, false if the table does not exist.
- Throws:
UnsupportedOperationException
- If the catalog does not support to purge a table.
-