ajantha-bhat commented on code in PR #8857:
URL: https://github.com/apache/iceberg/pull/8857#discussion_r1363886834
##########
nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java:
##########
@@ -181,23 +183,52 @@ 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();
- refresh();
- } catch (NessieNamespaceAlreadyExistsException e) {
- throw new AlreadyExistsException(e, "Namespace already exists: %s",
namespace);
- } catch (NessieNotFoundException e) {
+ org.projectnessie.model.Namespace content =
+ org.projectnessie.model.Namespace.of(metadata, namespace.levels());
+ ContentKey key = content.toContentKey();
+
+ CommitMultipleOperationsBuilder commitBuilder =
+ api.commitMultipleOperations()
+ .commitMeta(NessieUtil.buildCommitMetadata("create namespace " +
key, catalogOptions))
+ .operation(Operation.Put.of(key, content));
+
+ Tasks.foreach(commitBuilder)
+ .retry(5)
+ // conflict can be thrown when parent namespace doesn't exist;
+ // bad request can be thrown when namespace already exists.
+ .stopRetryOn(
+ NessieNotFoundException.class,
+ NessieConflictException.class,
Review Comment:
do we need to stop retrying on `NessieConflictException`? It depends on
conflict reason right?
Sometimes refresh() (which we do on retry), will help in succeeding the
commit using new head?
--
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]