Skip to content

Implement list_views to the Hive catalog - #3717

Open
nhuantho wants to merge 6 commits into
apache:mainfrom
nhuantho:hive-catalog/add-list_views
Open

Implement list_views to the Hive catalog#3717
nhuantho wants to merge 6 commits into
apache:mainfrom
nhuantho:hive-catalog/add-list_views

Conversation

@nhuantho

Copy link
Copy Markdown

Rationale for this change

I want to add list_views to the Hive catalog

Are these changes tested?

Added test_list_views

Comment thread pyiceberg/catalog/hive.py Outdated
raise NotImplementedError
"""List Iceberg views under the given namespace in the catalog.

When the database doesn't exist, it will just return an empty list.

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.

I think we should throw an exception if the database doesn't exist.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It makes sense; I will fix it.

Comment thread pyiceberg/catalog/hive.py Outdated
Comment on lines +500 to +504
(database_name, table.tableName)
for table in open_client.get_table_objects_by_name(
dbname=database_name, tbl_names=open_client.get_all_tables(db_name=database_name)
)
if table.parameters.get(TABLE_TYPE, "").lower() == ICEBERG_VIEW

@ebyhr ebyhr Jul 27, 2026

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.

Getting all tables and filtering them at the caller's side is slow, and HMS may become unstable. We should consider providing a VIRTUAL_VIEW condition.

However, follow-up is still acceptable. Pre-existing for list_tables.

Comment thread pyiceberg/catalog/hive.py Outdated
Comment on lines +486 to +495
When the database doesn't exist, it will just return an empty list.

Args:
namespace: Database to list.

Returns:
List[Identifier]: list of views identifiers.

Raises:
NoSuchNamespaceError: If a namespace with the given name does not exist, or the identifier is invalid.

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.

When the database doesn't exist, it will just return an empty list.
...
NoSuchNamespaceError: If a namespace with the given name does not exist

These sentences appear contradictory.

assert "Database default already exists" in str(exc_info.value)


def test_list_views(hive_table: HiveTable) -> None:

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.

Can we add an integration test? Create a view by Spark, and list it by PyIceberg.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I added an integration test for HiveCatalog.list_views

dbname="database", tbl_names=["table1", "table2", "table3", "table4"]
)


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.

I recommend adding a negative test - specifying a non-existing database.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I added test_list_views_to_namespace_does_not_exists

@nhuantho
nhuantho requested a review from ebyhr July 28, 2026 16:37
@jayceslesar

Copy link
Copy Markdown
Contributor

Please move the integration test to the common suite https://github.com/apache/iceberg-python/blob/main/tests/integration/test_catalog.py#L624

@jayceslesar

Copy link
Copy Markdown
Contributor

Sorry I should have been a little more explicit, the common catalog integration test suite is designed to cover as much testing as possible while re-using the same tests, just different catalog features. I think it would be wise to properly add a list_views test for the hive catalog in there, instead of just copying the new test in.

@nhuantho

Copy link
Copy Markdown
Author

@jayceslesar, thanks for your suggestion.

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.

3 participants