@Internal public final class CatalogManager extends Object implements CatalogRegistry, AutoCloseable
| Modifier and Type | Class and Description |
|---|---|
static class |
CatalogManager.Builder
Builder for a fluent definition of a
CatalogManager. |
| Modifier and Type | Method and Description |
|---|---|
void |
alterDatabase(String catalogName,
String databaseName,
org.apache.flink.table.catalog.CatalogDatabase newDatabase,
boolean ignoreIfNotExists)
Modify an existing database.
|
void |
alterTable(org.apache.flink.table.catalog.CatalogBaseTable table,
List<org.apache.flink.table.catalog.TableChange> changes,
org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier,
boolean ignoreIfNotExists)
Alters a table in a given fully qualified path with table changes.
|
void |
alterTable(org.apache.flink.table.catalog.CatalogBaseTable table,
org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier,
boolean ignoreIfNotExists)
Alters a table in a given fully qualified path.
|
void |
close()
Closes the catalog manager and releases its resources.
|
void |
createCatalog(String catalogName,
org.apache.flink.table.catalog.CatalogDescriptor catalogDescriptor)
Creates a catalog under the given name.
|
void |
createDatabase(String catalogName,
String databaseName,
org.apache.flink.table.catalog.CatalogDatabase database,
boolean ignoreIfExists)
Create a database.
|
void |
createTable(org.apache.flink.table.catalog.CatalogBaseTable table,
org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier,
boolean ignoreIfExists)
Creates a table in a given fully qualified path.
|
void |
createTemporaryTable(org.apache.flink.table.catalog.CatalogBaseTable table,
org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier,
boolean ignoreIfExists)
Creates a temporary table in a given fully qualified path.
|
void |
dropDatabase(String catalogName,
String databaseName,
boolean ignoreIfNotExists,
boolean cascade)
Drop a database.
|
void |
dropTable(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier,
boolean ignoreIfNotExists)
Drops a table in a given fully qualified path.
|
void |
dropTemporaryTable(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier,
boolean ignoreIfNotExists)
Drop a temporary table in a given fully qualified path.
|
void |
dropTemporaryView(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier,
boolean ignoreIfNotExists)
Drop a temporary view in a given fully qualified path.
|
void |
dropView(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier,
boolean ignoreIfNotExists)
Drops a view in a given fully qualified path.
|
String |
getBuiltInCatalogName()
Gets the built-in catalog name.
|
String |
getBuiltInDatabaseName()
Gets the built-in database name in the built-in catalog.
|
Optional<org.apache.flink.table.catalog.Catalog> |
getCatalog(String catalogName)
Gets a
Catalog instance by name. |
Optional<org.apache.flink.table.catalog.ResolvedCatalogBaseTable<?>> |
getCatalogBaseTable(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier)
Retrieves a fully qualified table.
|
List<CatalogModificationListener> |
getCatalogModificationListeners() |
org.apache.flink.table.catalog.Catalog |
getCatalogOrError(String catalogName)
Gets a catalog by name.
|
org.apache.flink.table.catalog.Catalog |
getCatalogOrThrowException(String catalogName) |
String |
getCurrentCatalog()
Gets the current catalog that will be used when resolving table path.
|
String |
getCurrentDatabase()
Gets the current database name that will be used when resolving table path.
|
org.apache.flink.table.catalog.DataTypeFactory |
getDataTypeFactory()
Returns a factory for creating fully resolved data types that can be used for planning.
|
Optional<org.apache.flink.table.catalog.CatalogPartition> |
getPartition(org.apache.flink.table.catalog.ObjectIdentifier tableIdentifier,
org.apache.flink.table.catalog.CatalogPartitionSpec partitionSpec)
Retrieves a partition with a fully qualified table path and partition spec.
|
org.apache.flink.table.catalog.SchemaResolver |
getSchemaResolver()
Returns a
SchemaResolver for creating ResolvedSchema from Schema. |
Optional<ContextResolvedTable> |
getTable(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier)
Retrieves a fully qualified table.
|
Optional<ContextResolvedTable> |
getTable(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier,
long timestamp)
Retrieves a fully qualified table with a specific time.
|
ContextResolvedTable |
getTableOrError(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier)
Like
getTable(ObjectIdentifier), but throws an error when the table is not available
in any of the catalogs. |
protected Optional<org.apache.flink.table.catalog.TemporaryOperationListener> |
getTemporaryOperationListener(org.apache.flink.table.catalog.ObjectIdentifier identifier) |
void |
initSchemaResolver(boolean isStreamingMode,
ExpressionResolver.ExpressionResolverBuilder expressionResolverBuilder)
Initializes a
SchemaResolver for Schema resolution. |
boolean |
isTemporaryTable(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier)
Return whether the table with a fully qualified table path is temporary or not.
|
Set<String> |
listCatalogs()
Retrieves the set of names of all registered catalogs, including all initialized catalogs and
all catalogs stored in the
CatalogStore. |
Set<String> |
listSchemas()
Lists all available schemas in the root of the catalog manager.
|
Set<String> |
listSchemas(String catalogName)
Lists all available schemas in the given catalog.
|
Set<String> |
listTables()
Returns an array of names of all tables (tables and views, both temporary and permanent)
registered in the namespace of the current catalog and database.
|
Set<String> |
listTables(String catalogName,
String databaseName)
Returns an array of names of all tables (tables and views, both temporary and permanent)
registered in the namespace of the given catalog and database.
|
Set<String> |
listTemporaryTables()
Returns an array of names of temporary tables registered in the namespace of the current
catalog and database.
|
Set<String> |
listTemporaryViews()
Returns an array of names of temporary views registered in the namespace of the current
catalog and database.
|
Set<String> |
listViews()
Returns an array of names of all views(both temporary and permanent) registered in the
namespace of the current catalog and database.
|
Set<String> |
listViews(String catalogName,
String databaseName)
Returns an array of names of all views(both temporary and permanent) registered in the
namespace of the given catalog and database.
|
static CatalogManager.Builder |
newBuilder() |
org.apache.flink.table.catalog.ObjectIdentifier |
qualifyIdentifier(org.apache.flink.table.catalog.UnresolvedIdentifier identifier)
Returns the full name of the given table path, this name may be padded with current
catalog/database name based on the
identifier's length. |
void |
registerCatalog(String catalogName,
org.apache.flink.table.catalog.Catalog catalog)
Deprecated.
This method is deprecated and will be removed in a future release. Use
createCatalog instead to create a catalog using CatalogDescriptor and store it
in the CatalogStore. |
org.apache.flink.table.catalog.ResolvedCatalogBaseTable<?> |
resolveCatalogBaseTable(org.apache.flink.table.catalog.CatalogBaseTable baseTable)
Resolves a
CatalogBaseTable to a validated ResolvedCatalogBaseTable. |
org.apache.flink.table.catalog.ResolvedCatalogTable |
resolveCatalogTable(org.apache.flink.table.catalog.CatalogTable table)
Resolves a
CatalogTable to a validated ResolvedCatalogTable. |
org.apache.flink.table.catalog.ResolvedCatalogView |
resolveCatalogView(org.apache.flink.table.catalog.CatalogView view)
Resolves a
CatalogView to a validated ResolvedCatalogView. |
Map<String,String> |
resolveCompactManagedTableOptions(org.apache.flink.table.catalog.ResolvedCatalogTable origin,
org.apache.flink.table.catalog.ObjectIdentifier tableIdentifier,
org.apache.flink.table.catalog.CatalogPartitionSpec partitionSpec)
Resolve dynamic options for compact operation on a Flink's managed table.
|
boolean |
schemaExists(String catalogName)
Checks if there is a catalog with given name or is there a temporary object registered within
a given catalog.
|
boolean |
schemaExists(String catalogName,
String databaseName)
Checks if there is a database with given name in a given catalog or is there a temporary
object registered within a given catalog and database.
|
void |
setCurrentCatalog(String catalogName)
Sets the current catalog name that will be used when resolving table path.
|
void |
setCurrentDatabase(String databaseName)
Sets the current database name that will be used when resolving a table path.
|
void |
unregisterCatalog(String catalogName,
boolean ignoreIfNotExists)
Unregisters a catalog under the given name.
|
@VisibleForTesting public List<CatalogModificationListener> getCatalogModificationListeners()
public static CatalogManager.Builder newBuilder()
public void close()
throws org.apache.flink.table.catalog.exceptions.CatalogException
This method closes all initialized catalogs and the catalog store.
close in interface AutoCloseableorg.apache.flink.table.catalog.exceptions.CatalogException - if an error occurs while closing the catalogs or the catalog storepublic void initSchemaResolver(boolean isStreamingMode,
ExpressionResolver.ExpressionResolverBuilder expressionResolverBuilder)
SchemaResolver for Schema resolution.
Currently, the resolver cannot be passed in the constructor because of a chicken-and-egg
problem between Planner and CatalogManager.
public org.apache.flink.table.catalog.SchemaResolver getSchemaResolver()
SchemaResolver for creating ResolvedSchema from Schema.public org.apache.flink.table.catalog.DataTypeFactory getDataTypeFactory()
public void createCatalog(String catalogName, org.apache.flink.table.catalog.CatalogDescriptor catalogDescriptor) throws org.apache.flink.table.catalog.exceptions.CatalogException
catalogName - the given catalog name under which to create the given catalogcatalogDescriptor - catalog descriptor for creating catalogorg.apache.flink.table.catalog.exceptions.CatalogException - If the catalog already exists in the catalog store or initialized
catalogs, or if an error occurs while creating the catalog or storing the CatalogDescriptor@Deprecated public void registerCatalog(String catalogName, org.apache.flink.table.catalog.Catalog catalog)
createCatalog instead to create a catalog using CatalogDescriptor and store it
in the CatalogStore.catalogName - name under which to register the given catalogcatalog - catalog to registerorg.apache.flink.table.catalog.exceptions.CatalogException - if the registration of the catalog under the given name failedpublic void unregisterCatalog(String catalogName, boolean ignoreIfNotExists)
If the catalog is in the initialized catalogs, it will be removed from the initialized
catalogs. If the catalog is stored in the CatalogStore, it will be removed from the
CatalogStore.
catalogName - name under which to unregister the given catalog.ignoreIfNotExists - If false exception will be thrown if the table or database or
catalog to be altered does not exist.org.apache.flink.table.catalog.exceptions.CatalogException - If the catalog does not exist in the initialized catalogs and not in
the CatalogStore, or if the remove operation failed.public Optional<org.apache.flink.table.catalog.Catalog> getCatalog(String catalogName)
Catalog instance by name.
If the catalog has already been initialized, the initialized instance will be returned
directly. Otherwise, the CatalogDescriptor will be obtained from the CatalogStore, and the catalog instance will be initialized.
catalogName - name of the catalog to retrievepublic org.apache.flink.table.catalog.Catalog getCatalogOrThrowException(String catalogName)
public org.apache.flink.table.catalog.Catalog getCatalogOrError(String catalogName) throws org.apache.flink.table.api.CatalogNotExistException
getCatalogOrError in interface CatalogRegistrycatalogName - name of the catalog to retrieveorg.apache.flink.table.api.CatalogNotExistException - if the catalog does not existpublic String getCurrentCatalog()
getCurrentCatalog in interface CatalogRegistryqualifyIdentifier(UnresolvedIdentifier)public void setCurrentCatalog(@Nullable String catalogName) throws org.apache.flink.table.api.CatalogNotExistException
catalogName - catalog name to set as current catalogorg.apache.flink.table.api.CatalogNotExistException - thrown if the catalog doesn't existqualifyIdentifier(UnresolvedIdentifier)public String getCurrentDatabase()
getCurrentDatabase in interface CatalogRegistryqualifyIdentifier(UnresolvedIdentifier)public void setCurrentDatabase(@Nullable String databaseName)
databaseName - database name to set as current database nameorg.apache.flink.table.catalog.exceptions.CatalogException - thrown if the database doesn't exist in the current catalogqualifyIdentifier(UnresolvedIdentifier),
setCurrentCatalog(String)public String getBuiltInCatalogName()
public String getBuiltInDatabaseName()
public Optional<ContextResolvedTable> getTable(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier)
qualifyIdentifier(UnresolvedIdentifier) first.objectIdentifier - full path of the table to retrievepublic Optional<ContextResolvedTable> getTable(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier, long timestamp)
qualifyIdentifier(UnresolvedIdentifier) first.objectIdentifier - full path of the table to retrievetimestamp - Timestamp of the table snapshot, which is milliseconds since 1970-01-01
00:00:00 UTCpublic Optional<org.apache.flink.table.catalog.ResolvedCatalogBaseTable<?>> getCatalogBaseTable(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier)
qualifyIdentifier(UnresolvedIdentifier) first.getCatalogBaseTable in interface CatalogRegistryobjectIdentifier - full path of the table to retrievepublic boolean isTemporaryTable(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier)
isTemporaryTable in interface CatalogRegistryobjectIdentifier - full path of the tablepublic ContextResolvedTable getTableOrError(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier)
getTable(ObjectIdentifier), but throws an error when the table is not available
in any of the catalogs.public Optional<org.apache.flink.table.catalog.CatalogPartition> getPartition(org.apache.flink.table.catalog.ObjectIdentifier tableIdentifier, org.apache.flink.table.catalog.CatalogPartitionSpec partitionSpec)
qualifyIdentifier(UnresolvedIdentifier) first.getPartition in interface CatalogRegistrytableIdentifier - full path of the table to retrievepartitionSpec - full partition specpublic Set<String> listCatalogs()
CatalogStore.public Set<String> listTables()
public Set<String> listTables(String catalogName, String databaseName)
public Set<String> listTemporaryTables()
public Set<String> listTemporaryViews()
public Set<String> listViews()
public Set<String> listViews(String catalogName, String databaseName)
public Set<String> listSchemas()
NOTE:It is primarily used for interacting with Calcite's schema.
public Set<String> listSchemas(String catalogName)
NOTE:It is primarily used for interacting with Calcite's schema.
catalogName - filter for the catalog part of the schemapublic boolean schemaExists(String catalogName)
NOTE:It is primarily used for interacting with Calcite's schema.
catalogName - filter for the catalog part of the schemapublic boolean schemaExists(String catalogName, String databaseName)
NOTE:It is primarily used for interacting with Calcite's schema.
catalogName - filter for the catalog part of the schemadatabaseName - filter for the database part of the schemapublic org.apache.flink.table.catalog.ObjectIdentifier qualifyIdentifier(org.apache.flink.table.catalog.UnresolvedIdentifier identifier)
identifier's length.qualifyIdentifier in interface CatalogRegistryidentifier - an unresolved identifierpublic void createTable(org.apache.flink.table.catalog.CatalogBaseTable table,
org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier,
boolean ignoreIfExists)
table - The table to put in the given path.objectIdentifier - The fully qualified path where to put the table.ignoreIfExists - If false exception will be thrown if a table exists in the given path.public void createTemporaryTable(org.apache.flink.table.catalog.CatalogBaseTable table,
org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier,
boolean ignoreIfExists)
table - The table to put in the given path.objectIdentifier - The fully qualified path where to put the table.ignoreIfExists - if false exception will be thrown if a table exists in the given path.public Map<String,String> resolveCompactManagedTableOptions(org.apache.flink.table.catalog.ResolvedCatalogTable origin, org.apache.flink.table.catalog.ObjectIdentifier tableIdentifier, org.apache.flink.table.catalog.CatalogPartitionSpec partitionSpec)
origin - The resolved managed table with enriched options.tableIdentifier - The fully qualified path of the managed table.partitionSpec - User-specified unresolved partition spec.public void dropTemporaryTable(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier,
boolean ignoreIfNotExists)
objectIdentifier - The fully qualified path of the table to drop.ignoreIfNotExists - If false exception will be thrown if the table to be dropped does
not exist.public void dropTemporaryView(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier,
boolean ignoreIfNotExists)
objectIdentifier - The fully qualified path of the view to drop.ignoreIfNotExists - If false exception will be thrown if the view to be dropped does not
exist.protected Optional<org.apache.flink.table.catalog.TemporaryOperationListener> getTemporaryOperationListener(org.apache.flink.table.catalog.ObjectIdentifier identifier)
public void alterTable(org.apache.flink.table.catalog.CatalogBaseTable table,
org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier,
boolean ignoreIfNotExists)
table - The table to put in the given pathobjectIdentifier - The fully qualified path where to alter the table.ignoreIfNotExists - If false exception will be thrown if the table or database or
catalog to be altered does not exist.public void alterTable(org.apache.flink.table.catalog.CatalogBaseTable table,
List<org.apache.flink.table.catalog.TableChange> changes,
org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier,
boolean ignoreIfNotExists)
table - The table to put in the given pathchanges - The table changes from the original table to the new table.objectIdentifier - The fully qualified path where to alter the table.ignoreIfNotExists - If false exception will be thrown if the table or database or
catalog to be altered does not exist.public void dropTable(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier,
boolean ignoreIfNotExists)
objectIdentifier - The fully qualified path of the table to drop.ignoreIfNotExists - If false exception will be thrown if the table to drop does not
exist.public void dropView(org.apache.flink.table.catalog.ObjectIdentifier objectIdentifier,
boolean ignoreIfNotExists)
objectIdentifier - The fully qualified path of the view to drop.ignoreIfNotExists - If false exception will be thrown if the view to drop does not
exist.public org.apache.flink.table.catalog.ResolvedCatalogBaseTable<?> resolveCatalogBaseTable(org.apache.flink.table.catalog.CatalogBaseTable baseTable)
CatalogBaseTable to a validated ResolvedCatalogBaseTable.public org.apache.flink.table.catalog.ResolvedCatalogTable resolveCatalogTable(org.apache.flink.table.catalog.CatalogTable table)
CatalogTable to a validated ResolvedCatalogTable.public org.apache.flink.table.catalog.ResolvedCatalogView resolveCatalogView(org.apache.flink.table.catalog.CatalogView view)
CatalogView to a validated ResolvedCatalogView.public void createDatabase(String catalogName, String databaseName, org.apache.flink.table.catalog.CatalogDatabase database, boolean ignoreIfExists) throws org.apache.flink.table.catalog.exceptions.DatabaseAlreadyExistException, org.apache.flink.table.catalog.exceptions.CatalogException
catalogName - Name of the catalog for databasedatabaseName - Name of the database to be createddatabase - The database definitionignoreIfExists - 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.org.apache.flink.table.catalog.exceptions.DatabaseAlreadyExistException - if the given database already exists and ignoreIfExists
is falseorg.apache.flink.table.catalog.exceptions.CatalogException - in case of any runtime exceptionpublic void dropDatabase(String catalogName, String databaseName, boolean ignoreIfNotExists, boolean cascade) throws org.apache.flink.table.catalog.exceptions.DatabaseNotExistException, org.apache.flink.table.catalog.exceptions.DatabaseNotEmptyException, org.apache.flink.table.catalog.exceptions.CatalogException
catalogName - Name of the catalog for database.databaseName - 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.org.apache.flink.table.catalog.exceptions.DatabaseNotExistException - if the given database does not existorg.apache.flink.table.catalog.exceptions.DatabaseNotEmptyException - if the given database is not empty and isRestrict is trueorg.apache.flink.table.catalog.exceptions.CatalogException - in case of any runtime exceptionpublic void alterDatabase(String catalogName, String databaseName, org.apache.flink.table.catalog.CatalogDatabase newDatabase, boolean ignoreIfNotExists) throws org.apache.flink.table.catalog.exceptions.DatabaseNotExistException, org.apache.flink.table.catalog.exceptions.CatalogException
catalogName - Name of the catalog for databasedatabaseName - Name of the database to be droppednewDatabase - The new database definitionignoreIfNotExists - Flag to specify behavior when the given database does not exist: if
set to false, throw an exception, if set to true, do nothing.org.apache.flink.table.catalog.exceptions.DatabaseNotExistException - if the given database does not existorg.apache.flink.table.catalog.exceptions.CatalogException - in case of any runtime exceptionCopyright © 2014–2024 The Apache Software Foundation. All rights reserved.