ajantha-bhat commented on code in PR #8909:
URL: https://github.com/apache/iceberg/pull/8909#discussion_r1401929044


##########
nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java:
##########
@@ -170,11 +184,12 @@ private TableIdentifier 
toIdentifier(EntriesResponse.Entry entry) {
     return TableIdentifier.of(elements.toArray(new String[elements.size()]));
   }
 
-  public IcebergTable table(TableIdentifier tableIdentifier) {
+  public <C extends IcebergContent> C asContent(

Review Comment:
   updated



##########
nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java:
##########
@@ -312,26 +327,32 @@ namespace, getRef().getName()),
   }
 
   public void renameTable(TableIdentifier from, TableIdentifier to) {
+    renameContent(from, to, Content.Type.ICEBERG_TABLE);
+  }
+
+  public void renameView(TableIdentifier from, TableIdentifier to) {
+    renameContent(from, to, Content.Type.ICEBERG_VIEW);
+  }
+
+  private void renameContent(TableIdentifier from, TableIdentifier to, 
Content.Type type) {
     getRef().checkMutable();
 
-    IcebergTable existingFromTable = table(from);
-    if (existingFromTable == null) {
-      throw new NoSuchTableException("Table does not exist: %s", from.name());
-    }
-    IcebergTable existingToTable = table(to);
-    if (existingToTable != null) {
-      throw new AlreadyExistsException("Table already exists: %s", to.name());
-    }
+    IcebergContent existingFromContent = asContent(from, IcebergContent.class);

Review Comment:
   updated



##########
nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java:
##########
@@ -312,26 +327,32 @@ namespace, getRef().getName()),
   }
 
   public void renameTable(TableIdentifier from, TableIdentifier to) {
+    renameContent(from, to, Content.Type.ICEBERG_TABLE);
+  }
+
+  public void renameView(TableIdentifier from, TableIdentifier to) {
+    renameContent(from, to, Content.Type.ICEBERG_VIEW);
+  }
+
+  private void renameContent(TableIdentifier from, TableIdentifier to, 
Content.Type type) {
     getRef().checkMutable();
 
-    IcebergTable existingFromTable = table(from);
-    if (existingFromTable == null) {
-      throw new NoSuchTableException("Table does not exist: %s", from.name());
-    }
-    IcebergTable existingToTable = table(to);
-    if (existingToTable != null) {
-      throw new AlreadyExistsException("Table already exists: %s", to.name());
-    }
+    IcebergContent existingFromContent = asContent(from, IcebergContent.class);
+    validateFromContentForRename(from, type, existingFromContent);
+
+    IcebergContent existingToContent = asContent(to, IcebergContent.class);
+    validateToContentForRename(from, to, existingToContent);
 
+    String contentType = type == Content.Type.ICEBERG_VIEW ? "view" : "table";

Review Comment:
   updated



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to