@Public public interface Catalog extends AutoCloseable
CatalogFactory
Modifier and Type | Interface and Description |
---|---|
static class |
Catalog.ColumnAlreadyExistException
Exception for trying to alter a column that already exists.
|
static class |
Catalog.ColumnNotExistException
Exception for trying to operate on a column that doesn't exist.
|
static class |
Catalog.DatabaseAlreadyExistException
Exception for trying to create a database that already exists.
|
static class |
Catalog.DatabaseNotEmptyException
Exception for trying to drop on a database that is not empty.
|
static class |
Catalog.DatabaseNotExistException
Exception for trying to operate on a database that doesn't exist.
|
static interface |
Catalog.Loader
Loader of
Catalog . |
static class |
Catalog.PartitionNotExistException
Exception for trying to operate on a partition that doesn't exist.
|
static class |
Catalog.ProcessSystemDatabaseException
Exception for trying to operate on a system database.
|
static class |
Catalog.TableAlreadyExistException
Exception for trying to create a table that already exists.
|
static class |
Catalog.TableNotExistException
Exception for trying to operate on a table that doesn't exist.
|
static class |
Catalog.ViewAlreadyExistException
Exception for trying to create a view that already exists.
|
static class |
Catalog.ViewNotExistException
Exception for trying to operate on a view that doesn't exist.
|
Modifier and Type | Field and Description |
---|---|
static String |
COMMENT_PROP |
static String |
DB_LOCATION_PROP |
static String |
DB_SUFFIX |
static String |
DEFAULT_DATABASE |
static String |
HIVE_LAST_UPDATE_TIME_PROP |
static String |
LAST_UPDATE_TIME_PROP |
static String |
NUM_FILES_PROP |
static String |
NUM_ROWS_PROP |
static String |
SYSTEM_BRANCH_PREFIX |
static String |
SYSTEM_DATABASE_NAME |
static String |
SYSTEM_TABLE_SPLITTER |
static String |
TABLE_DEFAULT_OPTION_PREFIX |
static String |
TOTAL_SIZE_PROP |
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. |
default void |
alterTable(Identifier identifier,
SchemaChange change,
boolean ignoreIfNotExists)
Modify an existing table from a
SchemaChange . |
default void |
createDatabase(String name,
boolean ignoreIfExists)
Create a database, see
createDatabase(String name, boolean ignoreIfExists, Map
properties) . |
void |
createDatabase(String name,
boolean ignoreIfExists,
Map<String,String> properties)
Create a database with properties.
|
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.
|
default 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.
|
default void |
dropView(Identifier identifier,
boolean ignoreIfNotExists)
Drop a view.
|
FileIO |
fileIO() |
Database |
getDatabase(String name)
Return a
Database identified by the given name. |
Table |
getTable(Identifier identifier)
Return a
Table identified by the given Identifier . |
Path |
getTableLocation(Identifier identifier)
Get the table location in this catalog.
|
default View |
getView(Identifier identifier)
Return a
View identified by the given Identifier . |
default void |
invalidateTable(Identifier identifier)
Invalidate cached table metadata for an
identifier . |
List<String> |
listDatabases()
Get the names of all databases in this catalog.
|
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.
|
default List<String> |
listViews(String databaseName)
Get names of all views under this database.
|
Map<String,String> |
options()
Catalog options.
|
void |
renameTable(Identifier fromTable,
Identifier toTable,
boolean ignoreIfNotExists)
Rename a table.
|
default void |
renameView(Identifier fromView,
Identifier toView,
boolean ignoreIfNotExists)
Rename a view.
|
default void |
repairCatalog() |
default void |
repairDatabase(String databaseName) |
default void |
repairTable(Identifier identifier) |
static Map<String,String> |
tableDefaultOptions(Map<String,String> options) |
static void |
validateCaseInsensitive(boolean caseSensitive,
String type,
List<String> names)
Validate database, table and field names must be lowercase when not case-sensitive.
|
static void |
validateCaseInsensitive(boolean caseSensitive,
String type,
String... names)
Validate database, table and field names must be lowercase when not case-sensitive.
|
String |
warehouse()
Warehouse root path containing all database directories in this catalog.
|
close
static final String DEFAULT_DATABASE
static final String SYSTEM_TABLE_SPLITTER
static final String SYSTEM_DATABASE_NAME
static final String SYSTEM_BRANCH_PREFIX
static final String COMMENT_PROP
static final String TABLE_DEFAULT_OPTION_PREFIX
static final String DB_LOCATION_PROP
static final String DB_SUFFIX
static final String NUM_ROWS_PROP
static final String NUM_FILES_PROP
static final String TOTAL_SIZE_PROP
static final String LAST_UPDATE_TIME_PROP
static final String HIVE_LAST_UPDATE_TIME_PROP
String warehouse()
FileIO fileIO()
List<String> listDatabases()
default void createDatabase(String name, boolean ignoreIfExists) throws Catalog.DatabaseAlreadyExistException
createDatabase(String name, boolean ignoreIfExists, Map
properties)
.void createDatabase(String name, boolean ignoreIfExists, Map<String,String> properties) throws Catalog.DatabaseAlreadyExistException
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 falseDatabase getDatabase(String name) throws Catalog.DatabaseNotExistException
Database
identified by the given name.name
- Database nameDatabase
Catalog.DatabaseNotExistException
- if the requested database does not existvoid dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade) throws Catalog.DatabaseNotExistException, Catalog.DatabaseNotEmptyException
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
Table getTable(Identifier identifier) throws Catalog.TableNotExistException
identifier
- Path of the tableCatalog.TableNotExistException
- if the target does not existPath getTableLocation(Identifier identifier)
List<String> listTables(String databaseName) throws Catalog.DatabaseNotExistException
NOTE: System tables will not be listed.
Catalog.DatabaseNotExistException
- if the database does not existvoid dropTable(Identifier identifier, boolean ignoreIfNotExists) throws Catalog.TableNotExistException
NOTE: System tables can not be dropped.
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 existvoid createTable(Identifier identifier, Schema schema, boolean ignoreIfExists) throws Catalog.TableAlreadyExistException, Catalog.DatabaseNotExistException
NOTE: System tables can not be created.
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 existvoid renameTable(Identifier fromTable, Identifier toTable, boolean ignoreIfNotExists) throws Catalog.TableNotExistException, Catalog.TableAlreadyExistException
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.
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 existsvoid alterTable(Identifier identifier, List<SchemaChange> changes, boolean ignoreIfNotExists) throws Catalog.TableNotExistException, Catalog.ColumnAlreadyExistException, Catalog.ColumnNotExistException
SchemaChange
s.
NOTE: System tables can not be altered.
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
default void invalidateTable(Identifier identifier)
identifier
.
If the table is already loaded or cached, drop cached data. If the table does not exist or is not cached, do nothing. Calling this method should not query remote services.
identifier
- a table identifiervoid createPartition(Identifier identifier, Map<String,String> partitionSpec) throws Catalog.TableNotExistException
Only catalog with metastore can support this method, and only table with 'metastore.partitioned-table' can support this method.
identifier
- path of the table to drop partitionpartitionSpec
- the partition to be createdCatalog.TableNotExistException
- if the table does not existvoid dropPartition(Identifier identifier, Map<String,String> partitions) throws Catalog.TableNotExistException, Catalog.PartitionNotExistException
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 existList<PartitionEntry> listPartitions(Identifier identifier) throws Catalog.TableNotExistException
identifier
- path of the table to list partitionsCatalog.TableNotExistException
- if the table does not existdefault void alterTable(Identifier identifier, SchemaChange change, boolean ignoreIfNotExists) throws Catalog.TableNotExistException, Catalog.ColumnAlreadyExistException, Catalog.ColumnNotExistException
SchemaChange
.
NOTE: System tables can not be altered.
identifier
- path of the table to be modifiedchange
- the schema changeignoreIfNotExists
- 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
default View getView(Identifier identifier) throws Catalog.ViewNotExistException
View
identified by the given Identifier
.identifier
- Path of the viewCatalog.ViewNotExistException
- if the target does not existdefault void dropView(Identifier identifier, boolean ignoreIfNotExists) throws Catalog.ViewNotExistException
identifier
- 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 existdefault void createView(Identifier identifier, View view, boolean ignoreIfExists) throws Catalog.ViewAlreadyExistException, Catalog.DatabaseNotExistException
identifier
- 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 existdefault List<String> listViews(String databaseName) throws Catalog.DatabaseNotExistException
Catalog.DatabaseNotExistException
- if the database does not existdefault void renameView(Identifier fromView, Identifier toView, boolean ignoreIfNotExists) throws Catalog.ViewNotExistException, Catalog.ViewAlreadyExistException
fromView
- identifier of the view to renametoView
- new view identifierCatalog.ViewNotExistException
- if the fromView does not existCatalog.ViewAlreadyExistException
- if the toView already existsboolean allowUpperCase()
default void repairCatalog()
default void repairDatabase(String databaseName)
default void repairTable(Identifier identifier) throws Catalog.TableNotExistException
Catalog.TableNotExistException
static void validateCaseInsensitive(boolean caseSensitive, String type, String... names)
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.