public class FileSystemCatalog extends AbstractCatalog
FileSystem
.Catalog.DatabaseAlreadyExistException, Catalog.DatabaseNotEmptyException, Catalog.DatabaseNotExistException, Catalog.TableAlreadyExistException, Catalog.TableNotExistException
DB_SUFFIX
DEFAULT_DATABASE, SYSTEM_TABLE_SPLITTER
Constructor and Description |
---|
FileSystemCatalog(org.apache.flink.core.fs.Path warehouse) |
Modifier and Type | Method and Description |
---|---|
void |
alterTable(org.apache.flink.table.catalog.ObjectPath tablePath,
List<SchemaChange> changes,
boolean ignoreIfNotExists)
Modify an existing table from
SchemaChange s. |
void |
close() |
void |
createDatabase(String name,
boolean ignoreIfExists)
Create a database.
|
void |
createTable(org.apache.flink.table.catalog.ObjectPath tablePath,
UpdateSchema table,
boolean ignoreIfExists)
Create a new table.
|
boolean |
databaseExists(String databaseName)
Check if a database exists in this catalog.
|
void |
dropDatabase(String name,
boolean ignoreIfNotExists,
boolean cascade)
Drop a database.
|
void |
dropTable(org.apache.flink.table.catalog.ObjectPath tablePath,
boolean ignoreIfNotExists)
Drop a table.
|
TableSchema |
getTableSchema(org.apache.flink.table.catalog.ObjectPath tablePath)
Return a
TableSchema identified by the given ObjectPath . |
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.
|
Optional<CatalogLock.Factory> |
lockFactory()
Get lock factory from catalog.
|
void |
renameTable(org.apache.flink.table.catalog.ObjectPath fromTable,
org.apache.flink.table.catalog.ObjectPath toTable,
boolean ignoreIfNotExists)
Rename a table.
|
boolean |
tableExists(org.apache.flink.table.catalog.ObjectPath tablePath)
Check if a table exists in this catalog.
|
protected String |
warehouse() |
databasePath, getTable, getTableLocation
public FileSystemCatalog(org.apache.flink.core.fs.Path warehouse)
public Optional<CatalogLock.Factory> lockFactory()
Catalog
public List<String> listDatabases()
Catalog
public boolean databaseExists(String databaseName)
Catalog
databaseName
- Name of the databasepublic void createDatabase(String name, boolean ignoreIfExists) throws Catalog.DatabaseAlreadyExistException
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.Catalog.DatabaseAlreadyExistException
- if the given database already exists and ignoreIfExists
is falsepublic void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade) throws Catalog.DatabaseNotExistException, Catalog.DatabaseNotEmptyException
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
Catalog.DatabaseNotExistException
- if the database does not existpublic TableSchema getTableSchema(org.apache.flink.table.catalog.ObjectPath tablePath) throws Catalog.TableNotExistException
Catalog
TableSchema
identified by the given ObjectPath
.tablePath
- Path of the tableCatalog.TableNotExistException
- if the target does not existpublic boolean tableExists(org.apache.flink.table.catalog.ObjectPath tablePath)
Catalog
tablePath
- Path of the tablepublic void dropTable(org.apache.flink.table.catalog.ObjectPath tablePath, boolean ignoreIfNotExists) throws Catalog.TableNotExistException
Catalog
tablePath
- 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(org.apache.flink.table.catalog.ObjectPath tablePath, UpdateSchema table, boolean ignoreIfExists) throws Catalog.TableAlreadyExistException, Catalog.DatabaseNotExistException
Catalog
tablePath
- path of the table to be createdtable
- 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 tablePath doesn't existpublic void renameTable(org.apache.flink.table.catalog.ObjectPath fromTable, org.apache.flink.table.catalog.ObjectPath toTable, boolean ignoreIfNotExists) throws Catalog.TableNotExistException, Catalog.TableAlreadyExistException
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 from table does not existCatalog.TableAlreadyExistException
- if the to table already existspublic void alterTable(org.apache.flink.table.catalog.ObjectPath tablePath, List<SchemaChange> changes, boolean ignoreIfNotExists) throws Catalog.TableNotExistException
Catalog
SchemaChange
s.tablePath
- 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 existprotected String warehouse()
warehouse
in class AbstractCatalog
Copyright © 2019–2023 The Apache Software Foundation. All rights reserved.