public abstract class AbstractCatalog extends Object implements Catalog
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 Options |
catalogOptions |
protected FileIO |
fileIO |
protected LineageMetaFactory |
lineageMetaFactory |
protected Map<String,String> |
tableDefaultOptions |
COMMENT_PROP, DB_LOCATION_PROP, DB_SUFFIX, DEFAULT_DATABASE, SYSTEM_BRANCH_PREFIX, SYSTEM_DATABASE_NAME, SYSTEM_TABLE_SPLITTER, TABLE_DEFAULT_OPTION_PREFIX| Modifier | Constructor and Description |
|---|---|
protected |
AbstractCatalog(FileIO fileIO) |
protected |
AbstractCatalog(FileIO fileIO,
Options options) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
allowUpperCase()
Return a boolean that indicates whether this catalog allow upper case.
|
Map<String,Map<String,Path>> |
allTablePaths() |
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) |
protected static void |
checkNotBranch(Identifier identifier,
String method) |
protected void |
checkNotSystemDatabase(String database)
Validate database cannot be a system database.
|
protected static void |
checkNotSystemTable(Identifier identifier,
String method) |
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 |
createTable(Identifier identifier,
Schema schema,
boolean ignoreIfExists)
Create a new table.
|
protected abstract void |
createTableImpl(Identifier identifier,
Schema schema) |
Optional<CatalogLockFactory> |
defaultLockFactory() |
void |
dropDatabase(String name,
boolean ignoreIfNotExists,
boolean cascade)
Drop a database.
|
protected abstract void |
dropDatabaseImpl(String name) |
void |
dropPartition(Identifier identifier,
Map<String,String> partitionSpec)
Drop the partition of the specify table.
|
void |
dropTable(Identifier identifier,
boolean ignoreIfNotExists)
Drop a table.
|
protected abstract void |
dropTableImpl(Identifier identifier) |
FileIO |
fileIO() |
protected abstract TableSchema |
getDataTableSchema(Identifier identifier) |
FormatTable |
getFormatTable(Identifier identifier)
Return a
FormatTable identified by the given Identifier. |
Table |
getTable(Identifier identifier)
Return a
Table identified by the given Identifier. |
Path |
getTableLocation(Identifier identifier)
Get the table location in this catalog.
|
static boolean |
isSpecifiedSystemTable(Identifier identifier) |
static boolean |
isSystemDatabase(String database) |
protected static boolean |
isSystemTable(Identifier identifier) |
protected List<String> |
listDatabasesInFileSystem(Path warehouse) |
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) |
Map<String,String> |
loadDatabaseProperties(String name)
Load database properties.
|
protected abstract Map<String,String> |
loadDatabasePropertiesImpl(String name) |
Optional<CatalogLockContext> |
lockContext()
Get lock context for lock factory to create a lock.
|
protected boolean |
lockEnabled() |
Optional<CatalogLockFactory> |
lockFactory()
Get lock factory from catalog.
|
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.
|
void |
renameTable(Identifier fromTable,
Identifier toTable,
boolean ignoreIfNotExists)
Rename a table.
|
protected abstract void |
renameTableImpl(Identifier fromTable,
Identifier toTable) |
protected boolean |
tableExistsInFileSystem(Path tablePath,
String branchName) |
Optional<TableSchema> |
tableSchemaInFileSystem(Path tablePath,
String branchName) |
protected void |
validateFieldNameCaseInsensitive(List<String> fieldNames) |
protected void |
validateIdentifierNameCaseInsensitive(Identifier identifier) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitalterTable, createDatabase, databaseExists, invalidateTable, listDatabases, metastoreClientFactory, repairCatalog, repairDatabase, repairTable, tableDefaultOptions, tableExists, validateCaseInsensitive, validateCaseInsensitive, warehousecloseprotected final FileIO fileIO
protected final Options catalogOptions
@Nullable protected final LineageMetaFactory lineageMetaFactory
protected AbstractCatalog(FileIO fileIO)
public Map<String,String> options()
Catalogpublic Optional<CatalogLockFactory> lockFactory()
CataloglockFactory in interface Catalogpublic Optional<CatalogLockFactory> defaultLockFactory()
public Optional<CatalogLockContext> lockContext()
CataloglockContext in interface Catalogprotected boolean lockEnabled()
public boolean allowUpperCase()
CatalogallowUpperCase 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 Map<String,String> loadDatabaseProperties(String name) throws Catalog.DatabaseNotExistException
CatalogloadDatabaseProperties in interface Catalogname - Database nameCatalog.DatabaseNotExistException - if the requested database does not existprotected abstract Map<String,String> loadDatabasePropertiesImpl(String name) throws Catalog.DatabaseNotExistException
public void dropPartition(Identifier identifier, Map<String,String> partitionSpec) throws Catalog.TableNotExistException
CatalogdropPartition in interface Catalogidentifier - path of the table to drop partitionpartitionSpec - the partition to be deletedCatalog.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 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 existprotected abstract void dropTableImpl(Identifier identifier)
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 FormatTable getFormatTable(Identifier identifier) throws Catalog.TableNotExistException
FormatTable identified by the given Identifier.identifier - Path of the tableCatalog.TableNotExistException - if the target does not existpublic Path newDatabasePath(String database)
database - The given database nameprotected abstract TableSchema getDataTableSchema(Identifier identifier) throws Catalog.TableNotExistException
Catalog.TableNotExistExceptionpublic Path getTableLocation(Identifier identifier)
CataloggetTableLocation in interface Catalogprotected static void checkNotBranch(Identifier identifier, String method)
protected void assertMainBranch(Identifier identifier)
public static boolean isSpecifiedSystemTable(Identifier identifier)
protected static boolean isSystemTable(Identifier identifier)
protected static void checkNotSystemTable(Identifier identifier, String method)
public static Path newTableLocation(String warehouse, Identifier identifier)
public static boolean isSystemDatabase(String database)
protected void checkNotSystemDatabase(String database)
protected void validateIdentifierNameCaseInsensitive(Identifier identifier)
protected void validateFieldNameCaseInsensitive(List<String> fieldNames)
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–2024 The Apache Software Foundation. All rights reserved.