Skip to content

Commit

Permalink
update alert database add multiply properties and update databases to…
Browse files Browse the repository at this point in the history
… database when operation on a database

fix typo
  • Loading branch information
jerry-024 committed Dec 16, 2024
1 parent c2cfcbe commit 240c30b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/content/program-api/catalog-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class ListDatabases {

## Drop Database

You can use the catalog to drop databases.
You can use the catalog to drop database.

```java
import org.apache.paimon.catalog.Catalog;
Expand All @@ -104,7 +104,7 @@ public class DropDatabase {

## Alter Database

You can use the catalog to alter databases.(ps: only support hive and jdbc catalog)
You can use the catalog to alter database's properties.(ps: only support hive and jdbc catalog)

```java
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -964,28 +964,47 @@ public void testTableUUID() throws Exception {

protected void alterDatabaseWhenSupportAlter() throws Exception {
// Alter database
String databaseName = "db_to_alter_alert";
String databaseName = "db_to_alter";
catalog.createDatabase(databaseName, false);
String key = "key";
String key = "key1";
String key2 = "key2";
// Add property
catalog.alterDatabase(
databaseName, Lists.newArrayList(DatabaseChange.setProperty(key, "value")), false);
databaseName,
Lists.newArrayList(
DatabaseChange.setProperty(key, "value"),
DatabaseChange.setProperty(key2, "value")),
false);
Database db = catalog.getDatabase(databaseName);
assertEquals("value", db.options().get(key));
assertEquals("value", db.options().get(key2));
// Update property
catalog.alterDatabase(
databaseName, Lists.newArrayList(DatabaseChange.setProperty(key, "value1")), false);
databaseName,
Lists.newArrayList(
DatabaseChange.setProperty(key, "value1"),
DatabaseChange.setProperty(key2, "value1")),
false);
db = catalog.getDatabase(databaseName);
assertEquals("value1", db.options().get(key));
assertEquals("value1", db.options().get(key2));
// remove property
catalog.alterDatabase(
databaseName, Lists.newArrayList(DatabaseChange.removeProperty(key)), false);
databaseName,
Lists.newArrayList(
DatabaseChange.removeProperty(key), DatabaseChange.removeProperty(key2)),
false);
db = catalog.getDatabase(databaseName);
assertEquals(false, db.options().containsKey(key));
assertEquals(false, db.options().containsKey(key2));
// Remove non-existent property
catalog.alterDatabase(
databaseName, Lists.newArrayList(DatabaseChange.removeProperty(key)), false);
databaseName,
Lists.newArrayList(
DatabaseChange.removeProperty(key), DatabaseChange.removeProperty(key2)),
false);
db = catalog.getDatabase(databaseName);
assertEquals(false, db.options().containsKey(key));
assertEquals(false, db.options().containsKey(key2));
}
}

0 comments on commit 240c30b

Please sign in to comment.