HIVE-29878: Support pagination for list endpoints in HMS REST Catalog and remove redundant type casting in REST Catalog - #6750
Aggarwal-Raghav wants to merge 3 commits into
Conversation
2b9d4af to
26cf388
Compare
26cf388 to
69ab1e2
Compare
|
CC @deniskuzZ , can you help with review? |
| namespace = Namespace.empty(); | ||
| } | ||
| return castResponse(ListNamespacesResponse.class, CatalogHandlers.listNamespaces(asNamespaceCatalog, namespace)); | ||
| String pageToken = PropertyUtil.propertyAsString(vars, "pageToken", null); |
There was a problem hiding this comment.
can we extract pagination to decorator lambda or similar? need test
|
gentle ping for review @deniskuzZ , have handled your review comments. |
| Class<T> responseType, | ||
| Supplier<Object> unpaginatedTask, | ||
| BiFunction<String, String, Object> paginatedTask) { | ||
| String pageToken = PropertyUtil.propertyAsString(properties, PAGE_TOKEN, null); |
There was a problem hiding this comment.
Only listNamespaces, listTables, and listViews and listFunctions supports pagination based on iceberg spec.
| return castResponse(ConfigResponse.class, ConfigResponse.builder().withEndpoints(endpoints).build()); | ||
| } | ||
|
|
||
| private <T extends RESTResponse> T executePaginated( |
There was a problem hiding this comment.
could we apply minor changes to design, how about
/** Paging parameters of a list request; present only when the client sent pageSize. */
private record PageRequest(String token, String size) {
static Optional<PageRequest> from(Map<String, String> vars) {
return Optional.ofNullable(vars.get(PAGE_SIZE))
.map(size -> new PageRequest(vars.get(PAGE_TOKEN), size));
}
}
private static <R> R paginateIfRequested(
Map<String, String> vars, Supplier<R> fullList, Function<PageRequest, R> page) {
return PageRequest.from(vars).map(page).orElseGet(fullList);
}
usage
private ListTablesResponse listTables(Map<String, String> vars) {
Namespace namespace = namespaceFromPathVars(vars);
return paginateIfRequested(vars,
() -> CatalogHandlers.listTables(catalog, namespace),
p -> CatalogHandlers.listTables(catalog, namespace, p.token(), p.size()));
}
why did we need castResponse at all?
There was a problem hiding this comment.
I kept castResponse because of original author's code. I think almost every return statement is wrapped with castResponse.
There was a problem hiding this comment.
but is that actually needed? if not - we can drop it in follow-up PR
There was a problem hiding this comment.
should I remove castRespose all together in this PR iteself?
There was a problem hiding this comment.
but is that actually needed?
i don't think so.
There was a problem hiding this comment.
should I remove castRespose all together in this PR iteself?
if that won't be a huge change, otherwise let's move it to follow-up. but drop it from pagination part of this PR
There was a problem hiding this comment.
Removed castResponse in this PR and update PR title and description
6c443e8 to
89d0354
Compare
89d0354 to
84f21ed
Compare
…atalog - Removed redundant castResponse method and BadResponseType exception - Replaced deprecated NAMESPACE_SPLITTER with RESTUtil.namespaceFromQueryParam - Extracted 'parent' string literal into PARENT constant
84f21ed to
8874536
Compare
|



What changes were proposed in this pull request?
This PR updates HMSCatalogAdapter to correctly extract pageToken and pageSize query parameters for the
listNamespaces,listTables, andlistViewsREST routes.Additionally, this PR performs several architectural cleanups to modernize the adapter:
castResponsemethod, leveraging Java generics.NAMESPACE_SPLITTERanddecodeNamespace(String)with modern Iceberg 1.11.0 equivalents (namespaceFromQueryParamanddecodeNamespace(..., "%1F")).Why are the changes needed?
Iceberg Rest Catalog Spec supports it as follows and this helps in catalog contains large number of tables.
Does this PR introduce any user-facing change?
NO
How was this patch tested?
Added
TestHMSCatalogAdapterPaginationJUnit test