public abstract class AbstractCatalog extends Object implements Catalog
Catalog.Catalog.BranchAlreadyExistException, Catalog.BranchNotExistException, Catalog.ColumnAlreadyExistException, Catalog.ColumnNotExistException, Catalog.DatabaseAlreadyExistException, Catalog.DatabaseNoPermissionException, Catalog.DatabaseNotEmptyException, Catalog.DatabaseNotExistException, Catalog.DialectAlreadyExistException, Catalog.DialectNotExistException, Catalog.ProcessSystemDatabaseException, Catalog.TableAlreadyExistException, Catalog.TableNoPermissionException, Catalog.TableNotExistException, Catalog.TagNotExistException, Catalog.ViewAlreadyExistException, Catalog.ViewNotExistException| Modifier and Type | Field and Description |
|---|---|
protected Options |
catalogOptions |
protected FileIO |
fileIO |
protected Map<String,String> |
tableDefaultOptions |
COMMENT_PROP, DB_LOCATION_PROP, DB_SUFFIX, DEFAULT_DATABASE, LAST_UPDATE_TIME_PROP, NUM_FILES_PROP, NUM_ROWS_PROP, OWNER_PROP, SYSTEM_BRANCH_PREFIX, SYSTEM_DATABASE_NAME, SYSTEM_TABLE_SPLITTER, TABLE_DEFAULT_OPTION_PREFIX, TOTAL_SIZE_PROP| Modifier | Constructor and Description |
|---|---|
protected |
AbstractCatalog(FileIO fileIO) |
protected |
AbstractCatalog(FileIO fileIO,
Options options) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
allowCustomTablePath() |
void |
alterDatabase(String name,
List<PropertyChange> changes,
boolean ignoreIfNotExists)
Alter a database.
|
protected abstract void |
alterDatabaseImpl(String name,
List<PropertyChange> changes) |
void |
alterPartitions(Identifier identifier,
List<PartitionStatistics> partitions)
Alter partitions of the specify table.
|
void |
alterTable(Identifier identifier,
List<SchemaChange> changes,
boolean ignoreIfNotExists)
Modify an existing table from
SchemaChanges. |
protected abstract void |
alterTableImpl(Identifier identifier,
List<SchemaChange> changes) |
protected void |
assertMainBranch(Identifier identifier) |
boolean |
commitSnapshot(Identifier identifier,
Snapshot snapshot,
List<PartitionStatistics> statistics)
Commit the
Snapshot for table identified by the given Identifier. |
void |
createBranch(Identifier identifier,
String branch,
String fromTag)
Create a new branch for this table.
|
void |
createDatabase(String name,
boolean ignoreIfExists,
Map<String,String> properties)
Create a database with properties.
|
protected abstract void |
createDatabaseImpl(String name,
Map<String,String> properties) |
void |
createFormatTable(Identifier identifier,
Schema schema)
Create a
FormatTable identified by the given Identifier. |
void |
createPartitions(Identifier identifier,
List<Map<String,String>> partitions)
Create partitions of the specify table.
|
void |
createTable(Identifier identifier,
Schema schema,
boolean ignoreIfExists)
Create a new table.
|
protected abstract void |
createTableImpl(Identifier identifier,
Schema schema) |
Optional<CatalogLockFactory> |
defaultLockFactory() |
void |
dropBranch(Identifier identifier,
String branch)
Drop the branch for this table.
|
void |
dropDatabase(String name,
boolean ignoreIfNotExists,
boolean cascade)
Drop a database.
|
protected abstract void |
dropDatabaseImpl(String name) |
void |
dropPartitions(Identifier identifier,
List<Map<String,String>> partitions)
Drop partitions of the specify table.
|
void |
dropTable(Identifier identifier,
boolean ignoreIfNotExists)
Drop a table.
|
protected abstract void |
dropTableImpl(Identifier identifier,
List<Path> externalPaths) |
void |
fastForward(Identifier identifier,
String branch)
Fast-forward a branch to main branch.
|
FileIO |
fileIO() |
protected FileIO |
fileIO(Path path) |
Database |
getDatabase(String name)
Return a
Database identified by the given name. |
protected abstract Database |
getDatabaseImpl(String name) |
Table |
getTable(Identifier identifier)
Return a
Table identified by the given Identifier. |
Path |
getTableLocation(Identifier identifier) |
List<String> |
listBranches(Identifier identifier)
List all branches of the table.
|
protected List<String> |
listDatabasesInFileSystem(Path warehouse) |
PagedList<String> |
listDatabasesPaged(Integer maxResults,
String pageToken)
Get paged list names of all databases in this catalog.
|
List<Partition> |
listPartitions(Identifier identifier)
Get Partition of all partitions of the table.
|
PagedList<Partition> |
listPartitionsPaged(Identifier identifier,
Integer maxResults,
String pageToken)
Get paged partitioned list of the table.
|
PagedList<Table> |
listTableDetailsPaged(String databaseName,
Integer maxResults,
String pageToken)
Get paged list of table details under this database.
|
protected PagedList<Table> |
listTableDetailsPagedImpl(String databaseName,
Integer maxResults,
String pageToken) |
List<String> |
listTables(String databaseName)
Get names of all tables under this database.
|
protected abstract List<String> |
listTablesImpl(String databaseName) |
protected List<String> |
listTablesInFileSystem(Path databasePath) |
PagedList<String> |
listTablesPaged(String databaseName,
Integer maxResults,
String pageToken)
Get paged list names of tables under this database.
|
Optional<TableSnapshot> |
loadSnapshot(Identifier identifier)
Return the snapshot of table identified by the given
Identifier. |
protected TableMetadata |
loadTableMetadata(Identifier identifier) |
protected abstract TableSchema |
loadTableSchema(Identifier identifier) |
Optional<CatalogLockContext> |
lockContext() |
protected boolean |
lockEnabled() |
Optional<CatalogLockFactory> |
lockFactory() |
void |
markDonePartitions(Identifier identifier,
List<Map<String,String>> partitions)
Mark partitions done of the specify table.
|
Path |
newDatabasePath(String database)
Get warehouse path for specified database.
|
static Path |
newDatabasePath(String warehouse,
String database) |
static Path |
newTableLocation(String warehouse,
Identifier identifier) |
Map<String,String> |
options()
Catalog options for re-creating this catalog.
|
void |
renameTable(Identifier fromTable,
Identifier toTable,
boolean ignoreIfNotExists)
Rename a table.
|
protected abstract void |
renameTableImpl(Identifier fromTable,
Identifier toTable) |
void |
rollbackTo(Identifier identifier,
Instant instant)
rollback table by the given
Identifier and instant. |
boolean |
supportsListObjectsPaged()
Whether this catalog supports version management for tables.
|
boolean |
supportsVersionManagement()
Whether this catalog supports version management for tables.
|
protected boolean |
tableExistsInFileSystem(Path tablePath,
String branchName) |
Optional<TableSchema> |
tableSchemaInFileSystem(Path tablePath,
String branchName) |
abstract String |
warehouse() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitalterTable, alterView, caseSensitive, catalogLoader, createDatabase, createView, dropView, getView, invalidateTable, listDatabases, listViewDetailsPaged, listViews, listViewsPaged, renameView, repairCatalog, repairDatabase, repairTablecloseprotected final FileIO fileIO
protected final Options catalogOptions
protected AbstractCatalog(FileIO fileIO)
public Map<String,String> options()
Catalogpublic abstract String warehouse()
public FileIO fileIO()
public Optional<CatalogLockFactory> lockFactory()
public Optional<CatalogLockFactory> defaultLockFactory()
public Optional<CatalogLockContext> lockContext()
protected boolean lockEnabled()
protected boolean allowCustomTablePath()
public PagedList<String> listDatabasesPaged(Integer maxResults, String pageToken)
CataloglistDatabasesPaged in interface CatalogmaxResults - Optional parameter indicating the maximum number of results to include in
the result. If maxResults is not specified or set to 0, will return the default number of
max results.pageToken - Optional parameter indicating the next page token allows list to be start
from a specific point.Catalog.supportsListObjectsPaged().public void createDatabase(String name, boolean ignoreIfExists, Map<String,String> properties) throws Catalog.DatabaseAlreadyExistException
CatalogcreateDatabase in interface Catalogname - Name of the database to be createdignoreIfExists - Flag to specify behavior when a database with the given name already
exists: if set to false, throw a DatabaseAlreadyExistException, if set to true, do
nothing.properties - properties to be associated with the databaseCatalog.DatabaseAlreadyExistException - if the given database already exists and ignoreIfExists
is falsepublic Database getDatabase(String name) throws Catalog.DatabaseNotExistException
CatalogDatabase identified by the given name.getDatabase in interface Catalogname - Database nameDatabaseCatalog.DatabaseNotExistException - if the requested database does not existprotected abstract Database getDatabaseImpl(String name) throws Catalog.DatabaseNotExistException
public void markDonePartitions(Identifier identifier, List<Map<String,String>> partitions) throws Catalog.TableNotExistException
CatalogmarkDonePartitions in interface Catalogidentifier - path of the table to mark done partitionspartitions - partitions to be marked doneCatalog.TableNotExistException - if the table does not existpublic List<Partition> listPartitions(Identifier identifier) throws Catalog.TableNotExistException
CataloglistPartitions in interface Catalogidentifier - path of the table to list partitionsCatalog.TableNotExistException - if the table does not existpublic PagedList<Partition> listPartitionsPaged(Identifier identifier, Integer maxResults, String pageToken) throws Catalog.TableNotExistException
CataloglistPartitionsPaged in interface Catalogidentifier - path of the table to list partitionsmaxResults - Optional parameter indicating the maximum number of results to include in
the result. If maxResults is not specified or set to 0, will return the default number of
max results.pageToken - Optional parameter indicating the next page token allows list to be start
from a specific point.Catalog.supportsListObjectsPaged().Catalog.TableNotExistException - if the table does not existprotected abstract void createDatabaseImpl(String name, Map<String,String> properties)
public void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade) throws Catalog.DatabaseNotExistException, Catalog.DatabaseNotEmptyException
CatalogdropDatabase in interface Catalogname - Name of the database to be dropped.ignoreIfNotExists - Flag to specify behavior when the database does not exist: if set to
false, throw an exception, if set to true, do nothing.cascade - Flag to specify behavior when the database contains table or function: if set
to true, delete all tables and functions in the database and then delete the database, if
set to false, throw an exception.Catalog.DatabaseNotEmptyException - if the given database is not empty and isRestrict is trueCatalog.DatabaseNotExistExceptionprotected abstract void dropDatabaseImpl(String name)
public void alterDatabase(String name, List<PropertyChange> changes, boolean ignoreIfNotExists) throws Catalog.DatabaseNotExistException
CatalogalterDatabase in interface Catalogname - Name of the database to alter.changes - the property changesignoreIfNotExists - Flag to specify behavior when the database does not exist: if set to
false, throw an exception, if set to true, do nothing.Catalog.DatabaseNotExistException - if the given database is not exist and ignoreIfNotExists is
falseprotected abstract void alterDatabaseImpl(String name, List<PropertyChange> changes) throws Catalog.DatabaseNotExistException
public List<String> listTables(String databaseName) throws Catalog.DatabaseNotExistException
CatalogNOTE: System tables will not be listed.
listTables in interface CatalogCatalog.DatabaseNotExistException - if the database does not existpublic PagedList<String> listTablesPaged(String databaseName, Integer maxResults, String pageToken) throws Catalog.DatabaseNotExistException
CatalogNOTE: System tables will not be listed.
listTablesPaged in interface CatalogdatabaseName - Name of the database to list tables.maxResults - Optional parameter indicating the maximum number of results to include in
the result. If maxResults is not specified or set to 0, will return the default number of
max results.pageToken - Optional parameter indicating the next page token allows list to be start
from a specific point.Catalog.supportsListObjectsPaged().Catalog.DatabaseNotExistException - if the database does not existpublic PagedList<Table> listTableDetailsPaged(String databaseName, Integer maxResults, String pageToken) throws Catalog.DatabaseNotExistException
CatalogNOTE: System tables will not be listed.
listTableDetailsPaged in interface CatalogdatabaseName - Name of the database to list table details.maxResults - Optional parameter indicating the maximum number of results to include in
the result. If maxResults is not specified or set to 0, will return the default number of
max results.pageToken - Optional parameter indicating the next page token allows list to be start
from a specific point.Catalog.supportsListObjectsPaged().Catalog.DatabaseNotExistException - if the database does not existprotected PagedList<Table> listTableDetailsPagedImpl(String databaseName, Integer maxResults, String pageToken) throws Catalog.DatabaseNotExistException
public void dropTable(Identifier identifier, boolean ignoreIfNotExists) throws Catalog.TableNotExistException
CatalogNOTE: System tables can not be dropped.
dropTable in interface Catalogidentifier - Path of the table to be droppedignoreIfNotExists - Flag to specify behavior when the table does not exist: if set to
false, throw an exception, if set to true, do nothing.Catalog.TableNotExistException - if the table does not existprotected abstract void dropTableImpl(Identifier identifier, List<Path> externalPaths)
public void createTable(Identifier identifier, Schema schema, boolean ignoreIfExists) throws Catalog.TableAlreadyExistException, Catalog.DatabaseNotExistException
CatalogNOTE: System tables can not be created.
createTable in interface Catalogidentifier - path of the table to be createdschema - the table definitionignoreIfExists - flag to specify behavior when a table already exists at the given path:
if set to false, it throws a TableAlreadyExistException, if set to true, do nothing.Catalog.TableAlreadyExistException - if table already exists and ignoreIfExists is falseCatalog.DatabaseNotExistException - if the database in identifier doesn't existprotected abstract void createTableImpl(Identifier identifier, Schema schema)
public void renameTable(Identifier fromTable, Identifier toTable, boolean ignoreIfNotExists) throws Catalog.TableNotExistException, Catalog.TableAlreadyExistException
CatalogNOTE: If you use object storage, such as S3 or OSS, please use this syntax carefully, because the renaming of object storage is not atomic, and only partial files may be moved in case of failure.
NOTE: System tables can not be renamed.
renameTable in interface CatalogfromTable - the name of the table which need to renametoTable - the new tableignoreIfNotExists - Flag to specify behavior when the table does not exist: if set to
false, throw an exception, if set to true, do nothing.Catalog.TableNotExistException - if the fromTable does not existCatalog.TableAlreadyExistException - if the toTable already existsprotected abstract void renameTableImpl(Identifier fromTable, Identifier toTable)
public void alterTable(Identifier identifier, List<SchemaChange> changes, boolean ignoreIfNotExists) throws Catalog.TableNotExistException, Catalog.ColumnAlreadyExistException, Catalog.ColumnNotExistException
CatalogSchemaChanges.
NOTE: System tables can not be altered.
alterTable in interface Catalogidentifier - path of the table to be modifiedchanges - the schema changesignoreIfNotExists - flag to specify behavior when the table does not exist: if set to
false, throw an exception, if set to true, do nothing.Catalog.TableNotExistException - if the table does not existCatalog.ColumnAlreadyExistExceptionCatalog.ColumnNotExistExceptionprotected abstract void alterTableImpl(Identifier identifier, List<SchemaChange> changes) throws Catalog.TableNotExistException, Catalog.ColumnAlreadyExistException, Catalog.ColumnNotExistException
public Table getTable(Identifier identifier) throws Catalog.TableNotExistException
CataloggetTable in interface Catalogidentifier - Path of the tableCatalog.TableNotExistException - if the target does not existpublic void createBranch(Identifier identifier, String branch, @Nullable String fromTag) throws Catalog.TableNotExistException, Catalog.BranchAlreadyExistException, Catalog.TagNotExistException
Catalog#fromTag, a branch will be created from the tag and the
data files will be inherited from it.createBranch in interface Catalogidentifier - path of the table, cannot be system or branch name.branch - the branch namefromTag - from the tagCatalog.TableNotExistException - if the table in identifier doesn't existCatalog.BranchAlreadyExistException - if the branch already existsCatalog.TagNotExistException - if the tag doesn't existpublic void dropBranch(Identifier identifier, String branch) throws Catalog.BranchNotExistException
CatalogdropBranch in interface Catalogidentifier - path of the table, cannot be system or branch name.branch - the branch nameCatalog.BranchNotExistException - if the branch doesn't existpublic void fastForward(Identifier identifier, String branch) throws Catalog.BranchNotExistException
CatalogfastForward in interface Catalogidentifier - path of the table, cannot be system or branch name.branch - the branch nameCatalog.BranchNotExistException - if the branch doesn't existpublic List<String> listBranches(Identifier identifier) throws Catalog.TableNotExistException
CataloglistBranches in interface Catalogidentifier - path of the table, cannot be system or branch name.Catalog.TableNotExistException - if the table in identifier doesn't existpublic boolean commitSnapshot(Identifier identifier, Snapshot snapshot, List<PartitionStatistics> statistics)
CatalogSnapshot for table identified by the given Identifier.commitSnapshot in interface Catalogidentifier - Path of the tablesnapshot - Snapshot to be committedstatistics - statistics information of this changepublic Optional<TableSnapshot> loadSnapshot(Identifier identifier)
CatalogIdentifier.loadSnapshot in interface Catalogidentifier - Path of the tablepublic void rollbackTo(Identifier identifier, Instant instant) throws Catalog.TableNotExistException
CatalogIdentifier and instant.rollbackTo in interface Catalogidentifier - path of the tableinstant - like snapshotId or tagNameCatalog.TableNotExistException - if the table does not existpublic boolean supportsListObjectsPaged()
CatalogCatalog.listTablesPaged(String, Integer,
String) would fall back to Catalog.listTables(String).
Catalog.listDatabasesPaged(Integer, String).
Catalog.listTablesPaged(String, Integer, String).
Catalog.listTableDetailsPaged(String, Integer, String).
Catalog.listViewsPaged(String, Integer, String).
Catalog.listViewDetailsPaged(String, Integer, String).
Catalog.listPartitionsPaged(Identifier, Integer, String).
supportsListObjectsPaged in interface Catalogpublic boolean supportsVersionManagement()
CatalogUnsupportedOperationException, affect the following methods:
supportsVersionManagement in interface Catalogpublic void createPartitions(Identifier identifier, List<Map<String,String>> partitions) throws Catalog.TableNotExistException
CatalogcreatePartitions in interface Catalogidentifier - path of the table to create partitionspartitions - partitions to be createdCatalog.TableNotExistException - if the table does not existpublic void dropPartitions(Identifier identifier, List<Map<String,String>> partitions) throws Catalog.TableNotExistException
CatalogdropPartitions in interface Catalogidentifier - path of the table to drop partitionspartitions - partitions to be deletedCatalog.TableNotExistException - if the table does not existpublic void alterPartitions(Identifier identifier, List<PartitionStatistics> partitions) throws Catalog.TableNotExistException
CatalogalterPartitions in interface Catalogidentifier - path of the table to alter partitionspartitions - partitions to be alteredCatalog.TableNotExistException - if the table does not existpublic void createFormatTable(Identifier identifier, Schema schema)
FormatTable identified by the given Identifier.identifier - Path of the tableschema - Schema of the tablepublic Path newDatabasePath(String database)
database - The given database nameprotected TableMetadata loadTableMetadata(Identifier identifier) throws Catalog.TableNotExistException
Catalog.TableNotExistExceptionprotected abstract TableSchema loadTableSchema(Identifier identifier) throws Catalog.TableNotExistException
Catalog.TableNotExistExceptionpublic Path getTableLocation(Identifier identifier)
protected void assertMainBranch(Identifier identifier)
public static Path newTableLocation(String warehouse, Identifier identifier)
protected List<String> listDatabasesInFileSystem(Path warehouse) throws IOException
IOExceptionprotected List<String> listTablesInFileSystem(Path databasePath) throws IOException
IOExceptionprotected boolean tableExistsInFileSystem(Path tablePath, String branchName)
public Optional<TableSchema> tableSchemaInFileSystem(Path tablePath, String branchName)
Copyright © 2023–2025 The Apache Software Foundation. All rights reserved.