Package org.apache.iceberg.catalog
Interface Catalog
- All Known Implementing Classes:
BaseMetastoreCatalog
,BaseMetastoreViewCatalog
,BaseSessionCatalog.AsCatalog
,CachingCatalog
,DynamoDbCatalog
,EcsCatalog
,GlueCatalog
,HadoopCatalog
,HiveCatalog
,InMemoryCatalog
,JdbcCatalog
,NessieCatalog
,RESTCatalog
,SnowflakeCatalog
public interface Catalog
A Catalog API for table create, drop, and load operations.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A builder used to create validtables
or start create/replacetransactions
. -
Method Summary
Modifier and TypeMethodDescriptiondefault Catalog.TableBuilder
buildTable
(TableIdentifier identifier, Schema schema) /** Instantiate a builder to either create a table or start a create/replace transaction.default Table
createTable
(TableIdentifier identifier, Schema schema) Create an unpartitioned table.default Table
createTable
(TableIdentifier identifier, Schema schema, PartitionSpec spec) Create a table.default Table
createTable
(TableIdentifier identifier, Schema schema, PartitionSpec spec, String location, Map<String, String> properties) Create a table.default Table
createTable
(TableIdentifier identifier, Schema schema, PartitionSpec spec, Map<String, String> properties) Create a table.default boolean
dropTable
(TableIdentifier identifier) Drop a table and delete all data and metadata files.boolean
dropTable
(TableIdentifier identifier, boolean purge) Drop a table; optionally delete data and metadata files.default void
initialize
(String name, Map<String, String> properties) Initialize a catalog given a custom name and a map of catalog properties.default void
invalidateTable
(TableIdentifier identifier) Invalidate cached table metadata from current catalog.listTables
(Namespace namespace) Return all the identifiers under this namespace.loadTable
(TableIdentifier identifier) Load a table.default String
name()
Return the name for this catalog.default Transaction
newCreateTableTransaction
(TableIdentifier identifier, Schema schema) Start a transaction to create a table.default Transaction
newCreateTableTransaction
(TableIdentifier identifier, Schema schema, PartitionSpec spec) Start a transaction to create a table.default Transaction
newCreateTableTransaction
(TableIdentifier identifier, Schema schema, PartitionSpec spec, String location, Map<String, String> properties) Start a transaction to create a table.default Transaction
newCreateTableTransaction
(TableIdentifier identifier, Schema schema, PartitionSpec spec, Map<String, String> properties) Start a transaction to create a table.default Transaction
newReplaceTableTransaction
(TableIdentifier identifier, Schema schema, boolean orCreate) Start a transaction to replace a table.default Transaction
newReplaceTableTransaction
(TableIdentifier identifier, Schema schema, PartitionSpec spec, boolean orCreate) Start a transaction to replace a table.default Transaction
newReplaceTableTransaction
(TableIdentifier identifier, Schema schema, PartitionSpec spec, String location, Map<String, String> properties, boolean orCreate) Start a transaction to replace a table.default Transaction
newReplaceTableTransaction
(TableIdentifier identifier, Schema schema, PartitionSpec spec, Map<String, String> properties, boolean orCreate) Start a transaction to replace a table.default Table
registerTable
(TableIdentifier identifier, String metadataFileLocation) Register a table with the catalog if it does not exist.void
renameTable
(TableIdentifier from, TableIdentifier to) Rename a table.default boolean
tableExists
(TableIdentifier identifier) Check whether table exists.
-
Method Details
-
name
Return the name for this catalog.- Returns:
- this catalog's name
-
listTables
Return all the identifiers under this namespace.- Parameters:
namespace
- a namespace- Returns:
- a list of identifiers for tables
- Throws:
NoSuchNamespaceException
- if the namespace is not found
-
createTable
default Table createTable(TableIdentifier identifier, Schema schema, PartitionSpec spec, String location, Map<String, String> properties) Create a table.- Parameters:
identifier
- a table identifierschema
- a schemaspec
- a partition speclocation
- a location for the table; leave null if unspecifiedproperties
- a string map of table properties- Returns:
- a Table instance
- Throws:
AlreadyExistsException
- if the table already exists
-
createTable
default Table createTable(TableIdentifier identifier, Schema schema, PartitionSpec spec, Map<String, String> properties) Create a table.- Parameters:
identifier
- a table identifierschema
- a schemaspec
- a partition specproperties
- a string map of table properties- Returns:
- a Table instance
- Throws:
AlreadyExistsException
- if the table already exists
-
createTable
Create a table.- Parameters:
identifier
- a table identifierschema
- a schemaspec
- a partition spec- Returns:
- a Table instance
- Throws:
AlreadyExistsException
- if the table already exists
-
createTable
Create an unpartitioned table.- Parameters:
identifier
- a table identifierschema
- a schema- Returns:
- a Table instance
- Throws:
AlreadyExistsException
- if the table already exists
-
newCreateTableTransaction
default Transaction newCreateTableTransaction(TableIdentifier identifier, Schema schema, PartitionSpec spec, String location, Map<String, String> properties) Start a transaction to create a table.- Parameters:
identifier
- a table identifierschema
- a schemaspec
- a partition speclocation
- a location for the table; leave null if unspecifiedproperties
- a string map of table properties- Returns:
- a
Transaction
to create the table - Throws:
AlreadyExistsException
- if the table already exists
-
newCreateTableTransaction
default Transaction newCreateTableTransaction(TableIdentifier identifier, Schema schema, PartitionSpec spec, Map<String, String> properties) Start a transaction to create a table.- Parameters:
identifier
- a table identifierschema
- a schemaspec
- a partition specproperties
- a string map of table properties- Returns:
- a
Transaction
to create the table - Throws:
AlreadyExistsException
- if the table already exists
-
newCreateTableTransaction
default Transaction newCreateTableTransaction(TableIdentifier identifier, Schema schema, PartitionSpec spec) Start a transaction to create a table.- Parameters:
identifier
- a table identifierschema
- a schemaspec
- a partition spec- Returns:
- a
Transaction
to create the table - Throws:
AlreadyExistsException
- if the table already exists
-
newCreateTableTransaction
Start a transaction to create a table.- Parameters:
identifier
- a table identifierschema
- a schema- Returns:
- a
Transaction
to create the table - Throws:
AlreadyExistsException
- if the table already exists
-
newReplaceTableTransaction
default Transaction newReplaceTableTransaction(TableIdentifier identifier, Schema schema, PartitionSpec spec, String location, Map<String, String> properties, boolean orCreate) Start a transaction to replace a table.- Parameters:
identifier
- a table identifierschema
- a schemaspec
- a partition speclocation
- a location for the table; leave null if unspecifiedproperties
- a string map of table propertiesorCreate
- whether to create the table if not exists- Returns:
- a
Transaction
to replace the table - Throws:
NoSuchTableException
- if the table doesn't exist and orCreate is false
-
newReplaceTableTransaction
default Transaction newReplaceTableTransaction(TableIdentifier identifier, Schema schema, PartitionSpec spec, Map<String, String> properties, boolean orCreate) Start a transaction to replace a table.- Parameters:
identifier
- a table identifierschema
- a schemaspec
- a partition specproperties
- a string map of table propertiesorCreate
- whether to create the table if not exists- Returns:
- a
Transaction
to replace the table - Throws:
NoSuchTableException
- if the table doesn't exist and orCreate is false
-
newReplaceTableTransaction
default Transaction newReplaceTableTransaction(TableIdentifier identifier, Schema schema, PartitionSpec spec, boolean orCreate) Start a transaction to replace a table.- Parameters:
identifier
- a table identifierschema
- a schemaspec
- a partition specorCreate
- whether to create the table if not exists- Returns:
- a
Transaction
to replace the table - Throws:
NoSuchTableException
- if the table doesn't exist and orCreate is false
-
newReplaceTableTransaction
default Transaction newReplaceTableTransaction(TableIdentifier identifier, Schema schema, boolean orCreate) Start a transaction to replace a table.- Parameters:
identifier
- a table identifierschema
- a schemaorCreate
- whether to create the table if not exists- Returns:
- a
Transaction
to replace the table - Throws:
NoSuchTableException
- if the table doesn't exist and orCreate is false
-
tableExists
Check whether table exists.- Parameters:
identifier
- a table identifier- Returns:
- true if the table exists, false otherwise
-
dropTable
Drop a table and delete all data and metadata files.- Parameters:
identifier
- a table identifier- Returns:
- true if the table was dropped, false if the table did not exist
-
dropTable
Drop a table; optionally delete data and metadata files.If purge is set to true the implementation should delete all data and metadata files.
- Parameters:
identifier
- a table identifierpurge
- if true, delete all data and metadata files in the table- Returns:
- true if the table was dropped, false if the table did not exist
-
renameTable
Rename a table.- Parameters:
from
- identifier of the table to renameto
- new table name- Throws:
NoSuchTableException
- if the from table does not existAlreadyExistsException
- if the to table already exists
-
loadTable
Load a table.- Parameters:
identifier
- a table identifier- Returns:
- instance of
Table
implementation referred bytableIdentifier
- Throws:
NoSuchTableException
- if the table does not exist
-
invalidateTable
Invalidate cached table metadata from current catalog.If the table is already loaded or cached, drop cached data. If the table does not exist or is not cached, do nothing.
- Parameters:
identifier
- a table identifier
-
registerTable
Register a table with the catalog if it does not exist.- Parameters:
identifier
- a table identifiermetadataFileLocation
- the location of a metadata file- Returns:
- a Table instance
- Throws:
AlreadyExistsException
- if the table already exists in the catalog.
-
buildTable
/** Instantiate a builder to either create a table or start a create/replace transaction.- Parameters:
identifier
- a table identifierschema
- a schema- Returns:
- the builder to create a table or start a create/replace transaction
-
initialize
Initialize a catalog given a custom name and a map of catalog properties.A custom Catalog implementation must have a no-arg constructor. A compute engine like Spark or Flink will first initialize the catalog without any arguments, and then call this method to complete catalog initialization with properties passed into the engine.
- Parameters:
name
- a custom name for the catalogproperties
- catalog properties
-