public class DelegateCatalog extends Object implements Catalog
Catalog.ColumnAlreadyExistException, Catalog.ColumnNotExistException, Catalog.DatabaseAlreadyExistException, Catalog.DatabaseNotEmptyException, Catalog.DatabaseNotExistException, Catalog.Loader, Catalog.PartitionNotExistException, Catalog.ProcessSystemDatabaseException, Catalog.TableAlreadyExistException, Catalog.TableNotExistException
Modifier and Type | Field and Description |
---|---|
protected Catalog |
wrapped |
COMMENT_PROP, DB_LOCATION_PROP, DB_SUFFIX, DEFAULT_DATABASE, SYSTEM_BRANCH_PREFIX, SYSTEM_DATABASE_NAME, SYSTEM_TABLE_SPLITTER, TABLE_DEFAULT_OPTION_PREFIX
Constructor and Description |
---|
DelegateCatalog(Catalog wrapped) |
Modifier and Type | Method and Description |
---|---|
boolean |
allowUpperCase()
Return a boolean that indicates whether this catalog allow upper case.
|
void |
alterTable(Identifier identifier,
List<SchemaChange> changes,
boolean ignoreIfNotExists)
Modify an existing table from
SchemaChange s. |
void |
close() |
void |
createDatabase(String name,
boolean ignoreIfExists,
Map<String,String> properties)
Create a database with properties.
|
void |
createTable(Identifier identifier,
Schema schema,
boolean ignoreIfExists)
Create a new table.
|
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.
|
FileIO |
fileIO() |
Table |
getTable(Identifier identifier)
Return a
Table identified by the given Identifier . |
Path |
getTableLocation(Identifier identifier)
Get the table location in this catalog.
|
List<String> |
listDatabases()
Get the names of all databases in this catalog.
|
List<String> |
listTables(String databaseName)
Get names of all tables under this database.
|
Map<String,String> |
loadDatabaseProperties(String name)
Load database properties.
|
Optional<CatalogLockContext> |
lockContext()
Get lock context for lock factory to create a lock.
|
Optional<CatalogLockFactory> |
lockFactory()
Get lock factory from catalog.
|
Optional<MetastoreClient.Factory> |
metastoreClientFactory(Identifier identifier)
Get metastore client factory for the table specified by
identifier . |
Map<String,String> |
options()
Catalog options.
|
void |
renameTable(Identifier fromTable,
Identifier toTable,
boolean ignoreIfNotExists)
Rename a table.
|
void |
repairCatalog() |
void |
repairDatabase(String databaseName) |
void |
repairTable(Identifier identifier) |
String |
warehouse()
Warehouse root path containing all database directories in this catalog.
|
Catalog |
wrapped() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
alterTable, createDatabase, databaseExists, invalidateTable, tableDefaultOptions, tableExists, validateCaseInsensitive, validateCaseInsensitive
protected final Catalog wrapped
public DelegateCatalog(Catalog wrapped)
public Catalog wrapped()
public boolean allowUpperCase()
Catalog
allowUpperCase
in interface Catalog
public String warehouse()
Catalog
public Map<String,String> options()
Catalog
public Optional<CatalogLockFactory> lockFactory()
Catalog
lockFactory
in interface Catalog
public Optional<CatalogLockContext> lockContext()
Catalog
lockContext
in interface Catalog
public Optional<MetastoreClient.Factory> metastoreClientFactory(Identifier identifier)
Catalog
identifier
.metastoreClientFactory
in interface Catalog
public List<String> listDatabases()
Catalog
listDatabases
in interface Catalog
public void createDatabase(String name, boolean ignoreIfExists, Map<String,String> properties) throws Catalog.DatabaseAlreadyExistException
Catalog
createDatabase
in interface Catalog
name
- 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 Map<String,String> loadDatabaseProperties(String name) throws Catalog.DatabaseNotExistException
Catalog
loadDatabaseProperties
in interface Catalog
name
- Database nameCatalog.DatabaseNotExistException
- if the requested database does not existpublic void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade) throws Catalog.DatabaseNotExistException, Catalog.DatabaseNotEmptyException
Catalog
dropDatabase
in interface Catalog
name
- 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.DatabaseNotExistException
public List<String> listTables(String databaseName) throws Catalog.DatabaseNotExistException
Catalog
NOTE: System tables will not be listed.
listTables
in interface Catalog
Catalog.DatabaseNotExistException
- if the database does not existpublic void dropTable(Identifier identifier, boolean ignoreIfNotExists) throws Catalog.TableNotExistException
Catalog
NOTE: System tables can not be dropped.
dropTable
in interface Catalog
identifier
- 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
Catalog
NOTE: System tables can not be created.
createTable
in interface Catalog
identifier
- 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
Catalog
NOTE: 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 Catalog
fromTable
- 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
Catalog
SchemaChange
s.
NOTE: System tables can not be altered.
alterTable
in interface Catalog
identifier
- 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.ColumnAlreadyExistException
Catalog.ColumnNotExistException
public Table getTable(Identifier identifier) throws Catalog.TableNotExistException
Catalog
getTable
in interface Catalog
identifier
- Path of the tableCatalog.TableNotExistException
- if the target does not existpublic Path getTableLocation(Identifier identifier)
Catalog
getTableLocation
in interface Catalog
public void dropPartition(Identifier identifier, Map<String,String> partitions) throws Catalog.TableNotExistException, Catalog.PartitionNotExistException
Catalog
dropPartition
in interface Catalog
identifier
- 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 void repairCatalog()
repairCatalog
in interface Catalog
public void repairDatabase(String databaseName)
repairDatabase
in interface Catalog
public void repairTable(Identifier identifier) throws Catalog.TableNotExistException
repairTable
in interface Catalog
Catalog.TableNotExistException
public void close() throws Exception
close
in interface AutoCloseable
Exception
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.