This is an automated email from the ASF dual-hosted git repository.
zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-go.git
The following commit(s) were added to refs/heads/main by this push:
new 4d748365 fix: explicitly pass purgeRequested=false in DropTable (#707)
4d748365 is described below
commit 4d748365e92dfa77b70fec078e16aa717303a928
Author: Shubhendu <[email protected]>
AuthorDate: Fri Feb 6 03:00:42 2026 +0530
fix: explicitly pass purgeRequested=false in DropTable (#707)
Summary
- DropTable now explicitly passes ?purgeRequested=false query parameter
- Ensures consistent behavior with catalog implementations that default
purge to true
Background
Some catalog implementations (e.g., MinIO) have changed their backend to
enable purge by default when no purgeRequested parameter is provided.
This caused DropTable to silently purge table data along with metadata,
which is unexpected behavior for users who only want to drop the table
metadata.
Signed-off-by: Shubhendu Ram Tripathi <[email protected]>
---
catalog/rest/rest.go | 7 ++++++-
catalog/rest/rest_test.go | 26 ++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/catalog/rest/rest.go b/catalog/rest/rest.go
index 3541d72c..1bd698e0 100644
--- a/catalog/rest/rest.go
+++ b/catalog/rest/rest.go
@@ -855,7 +855,12 @@ func (r *Catalog) DropTable(ctx context.Context,
identifier table.Identifier) er
return err
}
- _, err = doDelete[struct{}](ctx, r.baseURI, []string{"namespaces", ns,
"tables", tbl}, r.cl,
+ uri := r.baseURI.JoinPath("namespaces", ns, "tables", tbl)
+ v := url.Values{}
+ v.Set("purgeRequested", "false")
+ uri.RawQuery = v.Encode()
+
+ _, err = doDelete[struct{}](ctx, uri, []string{}, r.cl,
map[int]error{http.StatusNotFound: catalog.ErrNoSuchTable})
return err
diff --git a/catalog/rest/rest_test.go b/catalog/rest/rest_test.go
index 561e0205..67c6c0d5 100644
--- a/catalog/rest/rest_test.go
+++ b/catalog/rest/rest_test.go
@@ -1461,6 +1461,9 @@ func (r *RestCatalogSuite) TestDropTable204() {
r.Equal(v, req.Header.Values(k))
}
+ // Verify purgeRequested=false is explicitly sent
+ r.Equal("false", req.URL.Query().Get("purgeRequested"))
+
// Return 204 No Content for successful deletion
w.WriteHeader(http.StatusNoContent)
})
@@ -1472,6 +1475,29 @@ func (r *RestCatalogSuite) TestDropTable204() {
r.NoError(err)
}
+func (r *RestCatalogSuite) TestPurgeTable204() {
+ // Mock the purge table endpoint
+ r.mux.HandleFunc("/v1/namespaces/fokko/tables/table", func(w
http.ResponseWriter, req *http.Request) {
+ r.Require().Equal(http.MethodDelete, req.Method)
+
+ for k, v := range TestHeaders {
+ r.Equal(v, req.Header.Values(k))
+ }
+
+ // Verify purgeRequested=true is sent for purge
+ r.Equal("true", req.URL.Query().Get("purgeRequested"))
+
+ // Return 204 No Content for successful purge
+ w.WriteHeader(http.StatusNoContent)
+ })
+
+ cat, err := rest.NewCatalog(context.Background(), "rest", r.srv.URL,
rest.WithOAuthToken(TestToken))
+ r.Require().NoError(err)
+
+ err = cat.PurgeTable(context.Background(),
catalog.ToIdentifier("fokko", "table"))
+ r.NoError(err)
+}
+
func (r *RestCatalogSuite) TestDropTable404() {
// Mock the drop table endpoint with 404 response
r.mux.HandleFunc("/v1/namespaces/fokko/tables/table", func(w
http.ResponseWriter, req *http.Request) {