You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by yu...@apache.org on 2026/05/08 17:50:55 UTC

(polaris) branch main updated: Service: Fix renameTable to return 204 instead of 200 (#4383)

This is an automated email from the ASF dual-hosted git repository.

flyrain pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new 8fc4150f79 Service: Fix renameTable to return 204 instead of 200 (#4383)
8fc4150f79 is described below

commit 8fc4150f79e81e8b0286b76c5685d4d6a07cf7be
Author: Vidit Ochani <vi...@gmail.com>
AuthorDate: Fri May 8 10:50:49 2026 -0700

    Service: Fix renameTable to return 204 instead of 200 (#4383)
---
 CHANGELOG.md                                               |  1 +
 .../java/org/apache/polaris/service/it/env/CatalogApi.java | 14 ++++++++++++++
 .../service/it/test/PolarisRestCatalogIntegrationBase.java | 13 +++++++++++++
 .../service/catalog/iceberg/IcebergCatalogAdapter.java     |  2 +-
 4 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 90228f4347..5edd81ba7b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -52,6 +52,7 @@ request adding CHANGELOG notes for breaking (!) changes and possibly other secti
 - The configuration option `polaris.event-listener.type` is deprecated and will be removed later. Please use `polaris.event-listener.types` instead.
 
 ### Fixes
+- Fixed `renameTable` to return HTTP 204 (No Content) instead of 200, as per the Iceberg REST Catalog spec.
 
 ### Commits
 
diff --git a/integration-tests/src/main/java/org/apache/polaris/service/it/env/CatalogApi.java b/integration-tests/src/main/java/org/apache/polaris/service/it/env/CatalogApi.java
index 5b80bf88d7..6546798be6 100644
--- a/integration-tests/src/main/java/org/apache/polaris/service/it/env/CatalogApi.java
+++ b/integration-tests/src/main/java/org/apache/polaris/service/it/env/CatalogApi.java
@@ -36,6 +36,7 @@ import org.apache.iceberg.exceptions.RESTException;
 import org.apache.iceberg.rest.ErrorHandler;
 import org.apache.iceberg.rest.ErrorHandlers;
 import org.apache.iceberg.rest.requests.CreateNamespaceRequest;
+import org.apache.iceberg.rest.requests.RenameTableRequest;
 import org.apache.iceberg.rest.responses.ListNamespacesResponse;
 import org.apache.iceberg.rest.responses.ListTablesResponse;
 import org.apache.iceberg.rest.responses.LoadCredentialsResponse;
@@ -152,6 +153,19 @@ public class CatalogApi extends PolarisRestApi {
     }
   }
 
+  public void renameTable(String catalog, TableIdentifier source, TableIdentifier destination) {
+    try (Response res =
+        request("v1/{cat}/tables/rename", Map.of("cat", catalog))
+            .post(
+                Entity.json(
+                    RenameTableRequest.builder()
+                        .withSource(source)
+                        .withDestination(destination)
+                        .build()))) {
+      assertThat(res.getStatus()).isEqualTo(NO_CONTENT.getStatusCode());
+    }
+  }
+
   public void dropTable(String catalog, TableIdentifier id) {
     String ns =
         NamespaceUtils.joinNamespace(id.namespace(), NamespaceUtils.DEFAULT_NAMESPACE_SEPARATOR);
diff --git a/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogIntegrationBase.java b/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogIntegrationBase.java
index e12740a6fe..0ed2d6a8bb 100644
--- a/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogIntegrationBase.java
+++ b/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogIntegrationBase.java
@@ -617,6 +617,19 @@ public abstract class PolarisRestCatalogIntegrationBase extends CatalogTests<RES
         .containsExactly(expectedGrant);
   }
 
+  @Test
+  public void testRenameTableReturns204() {
+    restCatalog.createNamespace(Namespace.of("rename_ns"));
+    restCatalog
+        .buildTable(TableIdentifier.of(Namespace.of("rename_ns"), "src_table"), SCHEMA)
+        .create();
+
+    catalogApi.renameTable(
+        currentCatalogName,
+        TableIdentifier.of(Namespace.of("rename_ns"), "src_table"),
+        TableIdentifier.of(Namespace.of("rename_ns"), "dst_table"));
+  }
+
   @Test
   public void testCreateTableWithOverriddenBaseLocation() {
     Catalog catalog = managementApi.getCatalog(currentCatalogName);
diff --git a/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogAdapter.java b/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogAdapter.java
index 98b1e46265..5862f7cb91 100644
--- a/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogAdapter.java
+++ b/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogAdapter.java
@@ -439,7 +439,7 @@ public class IcebergCatalogAdapter
         prefix,
         catalog -> {
           catalog.renameTable(renameTableRequest);
-          return Response.ok(Response.Status.NO_CONTENT).build();
+          return Response.status(Response.Status.NO_CONTENT).build();
         });
   }