tanmayrauth commented on code in PR #1461:
URL: https://github.com/apache/iceberg-go/pull/1461#discussion_r3574220401
##########
catalog/rest/rest.go:
##########
@@ -2045,3 +2045,44 @@ func (r *Catalog) LoadView(ctx context.Context,
identifier table.Identifier) (*v
return view.New(identifier, metadata, rsp.MetadataLoc), nil
}
+
+func (r *Catalog) RenameView(ctx context.Context, from, to table.Identifier)
(*view.View, error) {
+ if err := r.endpoints.check(endpointRenameView); err != nil {
+ return nil, err
+ }
+ if err := catalog.ValidateViewIdentifier(from); err != nil {
+ return nil, err
+ }
+ if err := catalog.ValidateViewIdentifier(to); err != nil {
+ return nil, err
+ }
+
+ type payload struct {
+ Source identifier `json:"source"`
+ Destination identifier `json:"destination"`
+ }
+ src := identifier{
+ Namespace: catalog.NamespaceFromIdent(from),
+ Name: catalog.TableNameFromIdent(from),
+ }
+ dst := identifier{
+ Namespace: catalog.NamespaceFromIdent(to),
+ Name: catalog.TableNameFromIdent(to),
+ }
+
+ path, err := endpointRenameView.reqPath()
+ if err != nil {
+ return nil, err
+ }
+
+ _, err = doPostAllowNoContent[payload, any](ctx, r.baseURI, path,
payload{Source: src, Destination: dst}, r.cl,
+ map[int]error{
+ http.StatusNotFound: catalog.ErrNoSuchView,
Review Comment:
The rename endpoint returns 404 for two distinct cases, a missing source
view AND a missing destination namespace (NoSuchNamespaceException) — and both
collapse to ErrNoSuchView here. Impact: a caller that does `errors.Is(err,
catalog.ErrNoSuchNamespace)` to auto-create the destination namespace and retry
will never fire, and the user gets a misleading "view does not exist" when the
real problem is the target namespace. CreateView just above (line 2003) maps
404 to ErrNoSuchNamespace for exactly this reason. Since both are 404 you can't
split them on status code alone (you'd need the response `type` field), so this
may be an accepted limitation — RenameTable has it too.
--
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]