Skip to content

feat: add load_view to REST catalog - #3224

Merged
geruh merged 5 commits into
apache:mainfrom
spr0els:load_view
May 7, 2026
Merged

feat: add load_view to REST catalog#3224
geruh merged 5 commits into
apache:mainfrom
spr0els:load_view

Conversation

@spr0els

Copy link
Copy Markdown
Contributor

Rationale for this change

This is part of #818 and implements the load_view method for REST catalogs.

Are these changes tested?

Unit tests are added for:

  • successful loading of a view
  • thrown 404 error when trying to load a non existing view

Are there any user-facing changes?

This adds the load_view method for REST catalogs

Comment threadpyiceberg/catalog/__init__.py Outdated
Comment on lines +651 to +652
You can also use this method to check for view existence using 'try catalog.load_view() except NoSuchViewError'.
Note: This method doesn't scan data stored in the view.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: I would say we remove these.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Updated the docstring

assert actual == expected


def test_load_view_404(rest_mock: Mocker) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would also add a test that should return a view does not exists when trying to load a table with loadView

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Correct me if I'm wrong, but isn't this case already covered with the test_load_view_404 test?
If no view with the same identifier as the table identifier is found in the warehouse, this would be the same case as loading a non existent view.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is implementation dependent on the server, so this is an edge case to return the correct exception

But the test is better placed in integration tests rather than mocking

Would be cool to also add integration tests to the test_catalog.py

Comment threadpyiceberg/catalog/__init__.py Outdated
Comment on lines +651 to +652
You can also use this method to check for view existence using 'try catalog.load_view() except NoSuchViewError'.
Note: This method doesn't scan data stored in the view.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment threadpyiceberg/catalog/rest/__init__.py Outdated
@spr0els
spr0els requested a review from geruhApril 16, 2026 09:14

@gabeigliogabeiglio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Apart from adding integration tests LGTM

@geruh

Copy link
Copy Markdown
Member

I think we just need a rebase here, and I agree with @gabeiglio on adding an integ test if tck has the view support.

@spr0els

Copy link
Copy Markdown
ContributorAuthor

I added integration tests to tests/integration/test_rest_catalog.py because most catalogs don't have the methods for view interaction implemented yet. Putting the tests in test_catalog.py would cause too much error handling for most catalogs at the moment imho.

@rambleraptorrambleraptor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm late to the party on this one, but this looks fantastic. Thanks for helping to push view support along!

Comment threadtests/catalog/test_rest.py Outdated
json={
"error": {
"message": "View does not exist: examples.non_existent_view in warehouse 8bcb0838-50fc-472d-9ddb-8feb89ef5f1e",
"type": "NoSuchNamespaceErrorException",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this NoSuchNamespaceErrorException instead of NoSuchViewException?

https://github.com/apache/iceberg/blob/f29a182eccc9287764a511767a79f741eb4135af/open-api/rest-catalog-open-api.yaml#L1648-L1657

404:
description:
Not Found - NoSuchViewException, view to load does not existcontent:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'examples:
ViewToLoadDoesNotExist:
$ref: '#/components/examples/NoSuchViewError'

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Good catch. I agree, this should be a NoSuchViewException.

There are a two tests for tables in the same file that also return the wrong error type. These should return NoSuchTableException.

"error": {
"message": "Table does not exist: examples.does_not_exists in warehouse 8bcb0838-50fc-472d-9ddb-8feb89ef5f1e",
"type": "NoSuchNamespaceErrorException",
"code": 404,

https://github.com/apache/iceberg/blob/8d0508308cd068778897c06d3a802740ed4305a6/open-api/rest-catalog-open-api.yaml#L1009-L1018

"error": {
"message": "Table does not exist: fokko.does_not_exists in warehouse 8bcb0838-50fc-472d-9ddb-8feb89ef5f1e",
"type": "NoSuchNamespaceErrorException",
"code": 404,

https://github.com/apache/iceberg/blob/8d0508308cd068778897c06d3a802740ed4305a6/open-api/rest-catalog-open-api.yaml#L1170-L1179

Should I fix all of these in one go or create a issue for the table tests?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can do them in a different PR to keep this focused on load_view

Comment threadtests/integration/test_rest_catalog.py Outdated
Co-authored-by: Yuya Ebihara <ebyhry@gmail.com>
@gabeiglio

Copy link
Copy Markdown
Contributor

thanks! lgtm cc: @geruh for when you can double check 😉

@geruhgeruh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm, thanks for the reviews everyone!!

@geruh
geruh merged commit 7fb55cd into apache:mainMay 7, 2026
16 checks passed
@ndrluisndrluis mentioned this pull request May 16, 2026
8 tasks
Sign up for freeto 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.

6 participants

@spr0els@geruh@gabeiglio@Fokko@rambleraptor@ebyhr