Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAIMON-3219][Flink] support create database with properties when inner catalog supports. #3224

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,14 @@ default boolean caseSensitive() {
return true;
}

/**
* Return a boolean that indicates whether this catalog supports create database with
* properties.
*/
default boolean supportDatabaseProperties() {
return false;
}

/** Exception for trying to drop on a database that is not empty. */
class DatabaseNotEmptyException extends Exception {
private static final String MSG = "Database %s is not empty.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ public Optional<CatalogLockContext> lockContext() {
return Optional.of(new JdbcCatalogLockContext(connections, catalogKey, options));
}

@Override
public boolean supportDatabaseProperties() {
return true;
}

private Lock lock(Identifier identifier) {
if (!lockEnabled()) {
return new Lock.EmptyLock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,23 @@ public CatalogDatabase getDatabase(String databaseName)
@Override
public void createDatabase(String name, CatalogDatabase database, boolean ignoreIfExists)
throws DatabaseAlreadyExistException, CatalogException {
// todo: flink hive catalog support create db with props
if (database != null) {
if (database.getProperties().size() > 0) {
throw new UnsupportedOperationException(
"Create database with properties is unsupported.");
}
try {
if (database != null) {
if (database.getProperties().size() > 0 && !catalog.supportDatabaseProperties()) {
throw new UnsupportedOperationException(
"Create database with properties is unsupported.");
}

if (database.getDescription().isPresent()
&& !database.getDescription().get().equals("")) {
throw new UnsupportedOperationException(
"Create database with description is unsupported.");
}
}
if (database.getDescription().isPresent()
&& !database.getDescription().get().equals("")) {
throw new UnsupportedOperationException(
"Create database with description is unsupported.");
}

try {
catalog.createDatabase(name, ignoreIfExists);
catalog.createDatabase(name, ignoreIfExists, database.getProperties());
} else {
catalog.createDatabase(name, ignoreIfExists);
}
} catch (Catalog.DatabaseAlreadyExistException e) {
throw new DatabaseAlreadyExistException(getName(), e.database());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ protected void createDatabaseImpl(String name, Map<String, String> properties) {
}
}

@Override
public boolean supportDatabaseProperties() {
return true;
}

private Database convertToHiveDatabase(String name, Map<String, String> properties) {
Database database = new Database();
database.setName(name);
Expand Down