public abstract class AbstractCatalog extends Object implements Catalog
Catalog
.Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractCatalog.TableMeta
Table metadata.
|
Catalog.ColumnAlreadyExistException, Catalog.ColumnNotExistException, Catalog.DatabaseAlreadyExistException, Catalog.DatabaseNotEmptyException, Catalog.DatabaseNotExistException, Catalog.Loader, Catalog.PartitionNotExistException, Catalog.ProcessSystemDatabaseException, Catalog.TableAlreadyExistException, Catalog.TableNotExistException, Catalog.ViewAlreadyExistException, Catalog.ViewNotExistException
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, HIVE_LAST_UPDATE_TIME_PROP, 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() |
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
SchemaChange s. |
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 |
createFormatTable(Identifier identifier,
Schema schema)
Create a
FormatTable identified by the given Identifier . |
void |
createPartition(Identifier identifier,
Map<String,String> partitionSpec)
Create the partition 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 |
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() |
Database |
getDatabase(String name)
Return a
Database identified by the given name. |
protected abstract Database |
getDatabaseImpl(String name) |
protected Table |
getDataOrFormatTable(Identifier identifier) |
protected AbstractCatalog.TableMeta |
getDataTableMeta(Identifier identifier) |
protected abstract TableSchema |
getDataTableSchema(Identifier 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 |
isTableInSystemDatabase(Identifier identifier) |
protected List<String> |
listDatabasesInFileSystem(Path warehouse) |
List<PartitionEntry> |
listPartitions(Identifier identifier)
Get PartitionEntry of all partitions of the table.
|
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) |
Optional<CatalogLockContext> |
lockContext() |
protected boolean |
lockEnabled() |
Optional<CatalogLockFactory> |
lockFactory() |
Optional<MetastoreClient.Factory> |
metastoreClientFactory(Identifier identifier,
TableSchema schema)
Get metastore client factory for the table specified by
identifier . |
Path |
newDatabasePath(String database)
Get warehouse path for specified database.
|
static Path |
newDatabasePath(String warehouse,
String database) |
static Path |
newTableLocation(String warehouse,
Identifier identifier) |
protected FileIO |
objectFileIO(String objectLocation)
Catalog implementation may override this method to provide
FileIO to object table. |
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, wait
alterTable, createDatabase, createView, dropView, getView, invalidateTable, listDatabases, listViews, renameView, repairCatalog, repairDatabase, repairTable, tableDefaultOptions, validateCaseInsensitive, validateCaseInsensitive, warehouse
close
protected final FileIO fileIO
protected final Options catalogOptions
@Nullable protected final LineageMetaFactory lineageMetaFactory
protected AbstractCatalog(FileIO fileIO)
public Map<String,String> options()
Catalog
public Optional<CatalogLockFactory> lockFactory()
public Optional<CatalogLockFactory> defaultLockFactory()
public Optional<CatalogLockContext> lockContext()
protected boolean lockEnabled()
public boolean allowUpperCase()
Catalog
allowUpperCase
in interface Catalog
protected boolean allowCustomTablePath()
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 Database getDatabase(String name) throws Catalog.DatabaseNotExistException
Catalog
Database
identified by the given name.getDatabase
in interface Catalog
name
- Database nameDatabase
Catalog.DatabaseNotExistException
- if the requested database does not existprotected abstract Database getDatabaseImpl(String name) throws Catalog.DatabaseNotExistException
public void createPartition(Identifier identifier, Map<String,String> partitionSpec) throws Catalog.TableNotExistException
Catalog
Only catalog with metastore can support this method, and only table with 'metastore.partitioned-table' can support this method.
createPartition
in interface Catalog
identifier
- path of the table to drop partitionpartitionSpec
- the partition to be createdCatalog.TableNotExistException
- if the table does not existpublic void dropPartition(Identifier identifier, Map<String,String> partitionSpec) throws Catalog.TableNotExistException
Catalog
dropPartition
in interface Catalog
identifier
- path of the table to drop partitionpartitionSpec
- the partition to be deletedCatalog.TableNotExistException
- if the table does not existpublic List<PartitionEntry> listPartitions(Identifier identifier) throws Catalog.TableNotExistException
Catalog
listPartitions
in interface Catalog
identifier
- path of the table to list partitionsCatalog.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
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
protected abstract void dropDatabaseImpl(String name)
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 existprotected abstract void dropTableImpl(Identifier identifier)
public 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 existprotected abstract void createTableImpl(Identifier identifier, Schema schema)
public 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 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
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
protected abstract void alterTableImpl(Identifier identifier, List<SchemaChange> changes) throws Catalog.TableNotExistException, Catalog.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 existprotected Table getDataOrFormatTable(Identifier identifier) throws Catalog.TableNotExistException
Catalog.TableNotExistException
protected FileIO objectFileIO(String objectLocation)
FileIO
to object table.public 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 AbstractCatalog.TableMeta getDataTableMeta(Identifier identifier) throws Catalog.TableNotExistException
Catalog.TableNotExistException
protected abstract TableSchema getDataTableSchema(Identifier identifier) throws Catalog.TableNotExistException
Catalog.TableNotExistException
public Optional<MetastoreClient.Factory> metastoreClientFactory(Identifier identifier, TableSchema schema)
identifier
.public Path getTableLocation(Identifier identifier)
Catalog
getTableLocation
in interface Catalog
protected static void checkNotBranch(Identifier identifier, String method)
protected void assertMainBranch(Identifier identifier)
public static boolean isSpecifiedSystemTable(Identifier identifier)
protected static boolean isTableInSystemDatabase(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
IOException
protected List<String> listTablesInFileSystem(Path databasePath) throws IOException
IOException
protected boolean tableExistsInFileSystem(Path tablePath, String branchName)
public Optional<TableSchema> tableSchemaInFileSystem(Path tablePath, String branchName)
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.