Skip to content

feat(rest): add RegisterView to REST catalog#753

Merged
zeroshade merged 1 commit intoapache:mainfrom
shtripat:register-view
Mar 4, 2026
Merged

feat(rest): add RegisterView to REST catalog#753
zeroshade merged 1 commit intoapache:mainfrom
shtripat:register-view

Conversation

@shtripat
Copy link
Contributor

Description:

Adds RegisterView(ctx, identifier, metadataLocation) to rest.Catalog, the view equivalent of the existing RegisterTable. The method POSTs to POST /v1/{prefix}/namespaces/{namespace}/register-view as defined in the Iceberg REST catalog OpenAPI specification.

Motivation

Fixes: #752

The only way to migrate a view between REST catalogs without this method is LoadView + CreateView. That approach is lossy: CreateView resets version-id to 1, reassigns default-catalog to the target catalog name, and creates a new UUID — producing a new view rather than a registration of the existing one. RegisterView avoids all of this by pointing the target catalog at the existing metadata file, exactly as RegisterTable does for tables.

Changes

  • catalog/rest/rest.go: RegisterView on *Catalog — POSTs {name, metadata-location} to /namespaces/{ns}/register-view, parses the response through the existing loadViewResponse path, maps 404 → ErrNoSuchNamespace and 409 → ErrViewAlreadyExists.
  • catalog/rest/rest_test.go: three test cases covering the 200, 404, and 409 responses, following the same structure as the existing TestRegisterTable{200,404,409} tests.

Related

Description:

Closes #[issue] (file the companion issue first and link it here)

Adds RegisterView(ctx, identifier, metadataLocation) to rest.Catalog,
the view equivalent of the existing RegisterTable. The method POSTs to POST
/v1/{prefix}/namespaces/{namespace}/register-view as defined in the
Iceberg REST catalog OpenAPI specification.

Motivation

The only way to migrate a view between REST catalogs without this method is
LoadView + CreateView. That approach is lossy: CreateView resets version-id to 1,
reassigns default-catalog to the target catalog name, and creates a new UUID
— producing a new view rather than a registration of the existing one.
RegisterView avoids all of this by pointing the target catalog at the existing
metadata file, exactly as RegisterTable does for tables.

Changes

- catalog/rest/rest.go: RegisterView on *Catalog — POSTs {name, metadata-location}
to /namespaces/{ns}/register-view, parses the response through the existing loadViewResponse
path, maps 404 → ErrNoSuchNamespace and 409 → ErrViewAlreadyExists.
- catalog/rest/rest_test.go: three test cases covering the 200, 404, and 409 responses,
following the same structure as the existing TestRegisterTable{200,404,409} tests.

Related

- Java implementation: apache/iceberg#14868
- REST OpenAPI spec: open-api/rest-catalog-open-api.yaml — operationId registerView
- Mailing list discussion: https://lists.apache.org/thread/mxqz0fp6vz3nt7nl70wgrz6d2gr41rzj

Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io>
Copy link
Member

@zeroshade zeroshade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@zeroshade zeroshade merged commit 1a546fc into apache:main Mar 4, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rest.Catalog: add RegisterView to mirror RegisterTable

3 participants