ajantha-bhat commented on code in PR #8857:
URL: https://github.com/apache/iceberg/pull/8857#discussion_r1363197313
##########
nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java:
##########
@@ -181,23 +181,38 @@ public IcebergTable table(TableIdentifier
tableIdentifier) {
}
public void createNamespace(Namespace namespace, Map<String, String>
metadata) {
+ getRef().checkMutable();
+
+ if (namespace.isEmpty()) {
+ throw new IllegalArgumentException("Creating empty namespaces is not
supported");
+ }
+
try {
- getRef().checkMutable();
- withReference(
- getApi()
- .createNamespace()
-
.namespace(org.projectnessie.model.Namespace.of(namespace.levels()))
- .properties(metadata))
- .create();
+ org.projectnessie.model.Namespace content =
+ org.projectnessie.model.Namespace.of(metadata, namespace.levels());
+ ContentKey key = content.toContentKey();
+
+ api.commitMultipleOperations()
Review Comment:
Can we also handle this for Drop namespace?
##########
nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java:
##########
@@ -181,23 +181,38 @@ public IcebergTable table(TableIdentifier
tableIdentifier) {
}
public void createNamespace(Namespace namespace, Map<String, String>
metadata) {
+ getRef().checkMutable();
+
+ if (namespace.isEmpty()) {
+ throw new IllegalArgumentException("Creating empty namespaces is not
supported");
+ }
+
try {
- getRef().checkMutable();
- withReference(
- getApi()
- .createNamespace()
-
.namespace(org.projectnessie.model.Namespace.of(namespace.levels()))
- .properties(metadata))
- .create();
+ org.projectnessie.model.Namespace content =
+ org.projectnessie.model.Namespace.of(metadata, namespace.levels());
+ ContentKey key = content.toContentKey();
+
+ api.commitMultipleOperations()
Review Comment:
We should wrap it with `withReference`, it handles using new client when
ref@hash is used by catalog (instead of latest hash)
##########
nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java:
##########
@@ -181,23 +181,38 @@ public IcebergTable table(TableIdentifier
tableIdentifier) {
}
public void createNamespace(Namespace namespace, Map<String, String>
metadata) {
+ getRef().checkMutable();
+
+ if (namespace.isEmpty()) {
+ throw new IllegalArgumentException("Creating empty namespaces is not
supported");
+ }
+
try {
- getRef().checkMutable();
- withReference(
- getApi()
- .createNamespace()
-
.namespace(org.projectnessie.model.Namespace.of(namespace.levels()))
- .properties(metadata))
- .create();
+ org.projectnessie.model.Namespace content =
+ org.projectnessie.model.Namespace.of(metadata, namespace.levels());
+ ContentKey key = content.toContentKey();
+
+ api.commitMultipleOperations()
+ .branch((Branch) getRef().getReference())
+ .commitMeta(NessieUtil.buildCommitMetadata("create namespace " +
key, catalogOptions))
+ .operation(Operation.Put.of(key, content))
+ .commit();
Review Comment:
we should also add a retry like `renameTable()` and `dropTable()`, only for
the `commitTable()` retry is not needed as Iceberg has a built in retry for it
from a transaction.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]