nastra commented on code in PR #7283:
URL: https://github.com/apache/iceberg/pull/7283#discussion_r1159558326
##########
nessie/src/main/java/org/apache/iceberg/nessie/NessieTableOperations.java:
##########
@@ -174,6 +185,38 @@ protected void doCommit(TableMetadata base, TableMetadata
metadata) {
}
}
+ private static void
handleReferenceConflictException(NessieReferenceConflictException ex) {
+ // Check if the server returned 'ReferenceConflicts' information
+ ReferenceConflicts referenceConflicts = ex.getErrorDetails();
+ if (referenceConflicts == null) {
+ return;
+ }
+
+ // Can only narrow down to a single exception, if there is only one
conflict.
+ List<Conflict> conflicts = referenceConflicts.conflicts();
+ if (conflicts.size() != 1) {
+ return;
+ }
+
+ Conflict conflict = conflicts.get(0);
+ ConflictType conflictType = conflict.conflictType();
+ if (conflictType != null) {
+ switch (conflictType) {
+ case NAMESPACE_ABSENT:
+ throw new NoSuchNamespaceException(ex, "Cannot find namespace %s",
conflict.key());
Review Comment:
would it make more sense to slightly adjust this to `"Namespace does not
exist: %s"`?
##########
nessie/src/main/java/org/apache/iceberg/nessie/NessieTableOperations.java:
##########
@@ -174,6 +185,38 @@ protected void doCommit(TableMetadata base, TableMetadata
metadata) {
}
}
+ private static void
handleReferenceConflictException(NessieReferenceConflictException ex) {
+ // Check if the server returned 'ReferenceConflicts' information
+ ReferenceConflicts referenceConflicts = ex.getErrorDetails();
+ if (referenceConflicts == null) {
+ return;
+ }
+
+ // Can only narrow down to a single exception, if there is only one
conflict.
+ List<Conflict> conflicts = referenceConflicts.conflicts();
+ if (conflicts.size() != 1) {
+ return;
+ }
+
+ Conflict conflict = conflicts.get(0);
+ ConflictType conflictType = conflict.conflictType();
+ if (conflictType != null) {
+ switch (conflictType) {
+ case NAMESPACE_ABSENT:
+ throw new NoSuchNamespaceException(ex, "Cannot find namespace %s",
conflict.key());
+ case NAMESPACE_NOT_EMPTY:
+ throw new NamespaceNotEmptyException(ex, "Namespace %s is not
empty", conflict.key());
+ case KEY_DOES_NOT_EXIST:
+ throw new NoSuchTableException(ex, "Table %s not found",
conflict.key());
Review Comment:
maybe: `Table does not exist: %s`
--
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]