org.apache.flink.table.catalog.exceptions.DatabaseNotEmptyException Java Examples

The following examples show how to use org.apache.flink.table.catalog.exceptions.DatabaseNotEmptyException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GenericInMemoryCatalog.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void dropDatabase(String databaseName, boolean ignoreIfNotExists)
		throws DatabaseNotExistException, DatabaseNotEmptyException {
	checkArgument(!StringUtils.isNullOrWhitespaceOnly(databaseName));

	if (databases.containsKey(databaseName)) {

		// Make sure the database is empty
		if (isDatabaseEmpty(databaseName)) {
			databases.remove(databaseName);
		} else {
			throw new DatabaseNotEmptyException(getName(), databaseName);
		}
	} else if (!ignoreIfNotExists) {
		throw new DatabaseNotExistException(getName(), databaseName);
	}
}
 
Example #2
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testDropDb_DatabaseNotEmptyException() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	catalog.createTable(path1, createTable(), false);

	exception.expect(DatabaseNotEmptyException.class);
	exception.expectMessage("Database db1 in catalog test-catalog is not empty");
	catalog.dropDatabase(db1, true);
}
 
Example #3
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testDropDb_DatabaseNotEmptyException() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	catalog.createTable(path1, createTable(), false);

	exception.expect(DatabaseNotEmptyException.class);
	exception.expectMessage("Database db1 in catalog test-catalog is not empty");
	catalog.dropDatabase(db1, true, false);
}
 
Example #4
Source File: AbstractReadOnlyCatalog.java    From bahir-flink with Apache License 2.0 4 votes vote down vote up
@Override
public void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade) throws DatabaseNotExistException, DatabaseNotEmptyException, CatalogException {
    throw UNSUPPORTED_ERR;
}
 
Example #5
Source File: AbstractJdbcCatalog.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade) throws DatabaseNotExistException, DatabaseNotEmptyException, CatalogException {
	throw new UnsupportedOperationException();
}
 
Example #6
Source File: Catalog.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Drop a database.
 *
 * @param name              Name of the database to be dropped.
 * @param ignoreIfNotExists Flag to specify behavior when the database does not exist:
 *                          if set to false, throw an exception,
 *                          if set to true, do nothing.
 * @throws DatabaseNotExistException if the given database does not exist
 * @throws CatalogException in case of any runtime exception
 */
void dropDatabase(String name, boolean ignoreIfNotExists) throws DatabaseNotExistException,
	DatabaseNotEmptyException, CatalogException;
 
Example #7
Source File: Catalog.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Drop a database.
 *
 * @param name              Name of the database to be dropped.
 * @param ignoreIfNotExists Flag to specify behavior when the database does not exist:
 *                          if set to false, throw an exception,
 *                          if set to true, do nothing.
 * @throws DatabaseNotExistException if the given database does not exist
 * @throws CatalogException in case of any runtime exception
 */
default void dropDatabase(String name, boolean ignoreIfNotExists) throws DatabaseNotExistException,
		DatabaseNotEmptyException, CatalogException{
	dropDatabase(name, ignoreIfNotExists, false);
}
 
Example #8
Source File: Catalog.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Drop a database.
 *
 * @param name              Name of the database to be dropped.
 * @param ignoreIfNotExists Flag to specify behavior when the database does not exist:
 *                           if set to false, throw an exception,
 *                           if set to true, do nothing.
 * @param 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.
 * @throws DatabaseNotExistException if the given database does not exist
 * @throws DatabaseNotEmptyException if the given database is not empty and isRestrict is true
 * @throws CatalogException in case of any runtime exception
 */
void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade) throws DatabaseNotExistException,
	DatabaseNotEmptyException, CatalogException;