zhoujinsong commented on code in PR #4283:
URL: https://github.com/apache/amoro/pull/4283#discussion_r3628650231
##########
amoro-ams/src/main/java/org/apache/amoro/server/catalog/InternalCatalog.java:
##########
@@ -56,6 +59,12 @@ public List<String> listDatabases() {
}
public void createDatabase(String databaseName) {
+ createDatabase(databaseName, Collections.emptyMap());
+ }
+
+ public void createDatabase(String databaseName, Map<String, String>
properties) {
+ Map<String, String> databaseProperties =
+ properties == null ? Collections.emptyMap() : new
HashMap<>(properties);
if (!databaseExists(databaseName)) {
doAsTransaction(
Review Comment:
**Correction**:
Sorry, my previous comment was misleading — there’s no need to manually call
`beginSession` here. We recommend using the pre-wrapped `doAsTransaction`
helper instead:
```java
Map<String, String> previousProperties = new HashMap<>();
doAsTransaction(
() -> {
DatabaseMetadata metadata =
getAs(
TableMetaMapper.class,
mapper -> mapper.selectDatabaseMetadataForUpdate(name(),
databaseName));
if (metadata == null) {
throw new ObjectNotExistsException(getDatabaseDesc(databaseName));
}
Map<String, String> properties =
metadata.getProperties() == null
? new HashMap<>()
: new HashMap<>(metadata.getProperties());
previousProperties.putAll(properties);
requestedRemovals.forEach(properties::remove);
properties.putAll(requestedUpdates);
doAsExisted(
TableMetaMapper.class,
mapper -> mapper.updateDatabaseProperties(name(), databaseName,
properties),
() -> new ObjectNotExistsException(getDatabaseDesc(databaseName)));
});
return previousProperties;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]