You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "flyingImer (via GitHub)" <gi...@apache.org> on 2026/09/09 00:35:27 UTC

Re: [PR] CLI: Add pagination support [polaris]

flyingImer commented on code in PR #5385:
URL: https://github.com/apache/polaris/pull/5385#discussion_r3963542783


##########
client/python/apache_polaris/cli/command/utils.py:
##########
@@ -28,6 +28,29 @@
 from apache_polaris.sdk.management import PolarisDefaultApi
 from apache_polaris.sdk.catalog import IcebergCatalogAPI
 from apache_polaris.cli.constants import UNIT_SEPARATOR, EntityType
+from apache_polaris.cli.exceptions import CliError
+
+
+def paginate(
+    list_function: Callable[..., Any], page_size: Optional[int] = None, **kwargs: Any
+) -> Generator[Any, None, None]:
+    """
+    Yield responses from a paginated list endpoint.
+
+    When page_size is None, a full response is fetched within a single request.
+    """
+    if page_size is not None and page_size < 1:
+        raise CliError(f"page-size must be a positive integer, got: {page_size}")
+    if page_size is None:
+        yield list_function(**kwargs)
+        return
+    page_token: Optional[str] = None

Review Comment:
   Could we start with an empty page token here? The generated SDK omits pageToken when given None, but the Iceberg REST contract uses an empty pageToken to opt into pagination. Polaris's federated listing path returns the full list with no continuation token when pageToken is absent, so --page-size has no effect there and this loop stops after one response. Initializing the token to "" would address this. Could we also add a request-level regression that checks pageToken= on the first request, then follows the returned token and emits all results?
   



-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org