public class DelegateCatalog extends Object implements Catalog
Catalog.ColumnAlreadyExistException, Catalog.ColumnNotExistException, Catalog.DatabaseAlreadyExistException, Catalog.DatabaseNoPermissionException, Catalog.DatabaseNotEmptyException, Catalog.DatabaseNotExistException, Catalog.PartitionNotExistException, Catalog.ProcessSystemDatabaseException, Catalog.TableAlreadyExistException, Catalog.TableNoPermissionException, Catalog.TableNotExistException, Catalog.ViewAlreadyExistException, Catalog.ViewNotExistException| Modifier and Type | Field and Description |
|---|---|
protected Catalog |
wrapped |
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| Constructor and Description |
|---|
DelegateCatalog(Catalog wrapped) |
| Modifier and Type | Method and Description |
|---|---|
void |
alterDatabase(String name,
List<PropertyChange> changes,
boolean ignoreIfNotExists)
Alter a database.
|
void |
alterTable(Identifier identifier,
List<SchemaChange> changes,
boolean ignoreIfNotExists)
Modify an existing table from
SchemaChanges. |
boolean |
caseSensitive()
Return a boolean that indicates whether this catalog is case-sensitive.
|
void |
close() |
void |
createDatabase(String name,
boolean ignoreIfExists,
Map<String,String> properties)
Create a database with properties.
|
void |
createPartition(Identifier identifier,
Map<String,String> partitions)
Create the partition of the specify table.
|
void |
createTable(Identifier identifier,
Schema schema,
boolean ignoreIfExists)
Create a new table.
|
void |
createView(Identifier identifier,
View view,
boolean ignoreIfExists)
Create a new view.
|
void |
dropDatabase(String name,
boolean ignoreIfNotExists,
boolean cascade)
Drop a database.
|
void |
dropPartition(Identifier identifier,
Map<String,String> partitions)
Drop the partition of the specify table.
|
void |
dropTable(Identifier identifier,
boolean ignoreIfNotExists)
Drop a table.
|
void |
dropView(Identifier identifier,
boolean ignoreIfNotExists)
Drop a view.
|
FileIO |
fileIO()
FileIO of this catalog. |
Database |
getDatabase(String name)
Return a
Database identified by the given name. |
Table |
getTable(Identifier identifier)
Return a
Table identified by the given Identifier. |
View |
getView(Identifier identifier)
Return a
View identified by the given Identifier. |
List<String> |
listDatabases()
Get the names of all databases in this catalog.
|
List<Partition> |
listPartitions(Identifier identifier)
Get Partition of all partitions of the table.
|
List<String> |
listTables(String databaseName)
Get names of all tables under this database.
|
List<String> |
listViews(String databaseName)
Get names of all views under this database.
|
Map<String,String> |
options()
Catalog options for re-creating this catalog.
|
void |
renameTable(Identifier fromTable,
Identifier toTable,
boolean ignoreIfNotExists)
Rename a table.
|
void |
renameView(Identifier fromView,
Identifier toView,
boolean ignoreIfNotExists)
Rename a view.
|
void |
repairCatalog()
Repair the entire Catalog, repair the metadata in the metastore consistent with the metadata
in the filesystem, register missing tables in the metastore.
|
void |
repairDatabase(String databaseName)
Repair the entire database, repair the metadata in the metastore consistent with the metadata
in the filesystem, register missing tables in the metastore.
|
void |
repairTable(Identifier identifier)
Repair the table, repair the metadata in the metastore consistent with the metadata in the
filesystem.
|
String |
warehouse()
Warehouse root path for creating new databases.
|
Catalog |
wrapped() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitalterTable, createDatabase, invalidateTableprotected final Catalog wrapped
public DelegateCatalog(Catalog wrapped)
public Catalog wrapped()
public boolean caseSensitive()
CatalogcaseSensitive in interface Catalogpublic String warehouse()
Catalogpublic Map<String,String> options()
Catalogpublic FileIO fileIO()
CatalogFileIO of this catalog. It can access Catalog.warehouse() path.public List<String> listDatabases()
CataloglistDatabases in interface Catalogpublic 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 existpublic 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.DatabaseNotExistExceptionpublic 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
falsepublic 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 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 existpublic 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 existpublic 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 existspublic 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.ColumnNotExistExceptionpublic Table getTable(Identifier identifier) throws Catalog.TableNotExistException
CataloggetTable in interface Catalogidentifier - Path of the tableCatalog.TableNotExistException - if the target does not existpublic View getView(Identifier identifier) throws Catalog.ViewNotExistException
CatalogView identified by the given Identifier.getView in interface Catalogidentifier - Path of the viewCatalog.ViewNotExistException - if the target does not existpublic void dropView(Identifier identifier, boolean ignoreIfNotExists) throws Catalog.ViewNotExistException
CatalogdropView in interface Catalogidentifier - Path of the view to be droppedignoreIfNotExists - Flag to specify behavior when the view does not exist: if set to
false, throw an exception, if set to true, do nothing.Catalog.ViewNotExistException - if the view does not existpublic void createView(Identifier identifier, View view, boolean ignoreIfExists) throws Catalog.ViewAlreadyExistException, Catalog.DatabaseNotExistException
CatalogcreateView in interface Catalogidentifier - path of the view to be createdview - the view definitionignoreIfExists - flag to specify behavior when a view already exists at the given path:
if set to false, it throws a ViewAlreadyExistException, if set to true, do nothing.Catalog.ViewAlreadyExistException - if view already exists and ignoreIfExists is falseCatalog.DatabaseNotExistException - if the database in identifier doesn't existpublic List<String> listViews(String databaseName) throws Catalog.DatabaseNotExistException
CataloglistViews in interface CatalogCatalog.DatabaseNotExistException - if the database does not existpublic void renameView(Identifier fromView, Identifier toView, boolean ignoreIfNotExists) throws Catalog.ViewNotExistException, Catalog.ViewAlreadyExistException
CatalogrenameView in interface CatalogfromView - identifier of the view to renametoView - new view identifierCatalog.ViewNotExistException - if the fromView does not existCatalog.ViewAlreadyExistException - if the toView already existspublic void createPartition(Identifier identifier, Map<String,String> partitions) throws Catalog.TableNotExistException
CatalogOnly catalog with metastore can support this method, and only table with 'metastore.partitioned-table' can support this method.
createPartition in interface Catalogidentifier - path of the table to drop partitionpartitions - the partition to be createdCatalog.TableNotExistException - if the table does not existpublic void dropPartition(Identifier identifier, Map<String,String> partitions) throws Catalog.TableNotExistException, Catalog.PartitionNotExistException
CatalogdropPartition in interface Catalogidentifier - path of the table to drop partitionpartitions - the partition to be deletedCatalog.TableNotExistException - if the table does not existCatalog.PartitionNotExistException - if the partition 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 void repairCatalog()
CatalogrepairCatalog in interface Catalogpublic void repairDatabase(String databaseName)
CatalogrepairDatabase in interface Catalogpublic void repairTable(Identifier identifier) throws Catalog.TableNotExistException
CatalogrepairTable in interface CatalogCatalog.TableNotExistExceptionpublic void close()
throws Exception
close in interface AutoCloseableExceptionCopyright © 2023–2025 The Apache Software Foundation. All rights reserved.