ebyhr commented on code in PR #3717:
URL: https://github.com/apache/iceberg-python/pull/3717#discussion_r3661730497
##########
pyiceberg/catalog/hive.py:
##########
@@ -480,7 +481,28 @@ def register_table(self, identifier: str | Identifier,
metadata_location: str, o
@override
def list_views(self, namespace: str | Identifier) -> list[Identifier]:
- 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.
+
+ 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.
+ """
+ database_name = self.identifier_to_database(namespace,
NoSuchNamespaceError)
+ with self._client as open_client:
+ return [
+ (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
Review Comment:
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.
--
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]