-
Notifications
You must be signed in to change notification settings - Fork 368
Implement GenericTableCatalogAdapter; admin-related fixes #1298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
eric-maynard
merged 34 commits into
apache:main
from
eric-maynard:generic-tables-rest-2
Apr 10, 2025
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
a5e5fa4
initial commit:
eric-maynard c5424c2
debugging
eric-maynard 3947e9c
some polish
eric-maynard 2ba331d
autolint
eric-maynard 4078a8d
spec change
eric-maynard 32349de
bugfix
eric-maynard 54fbe31
bugfix
eric-maynard 21ccc65
various fixes
eric-maynard 119beab
another missing admin location
eric-maynard 9c299b6
autolint
eric-maynard 44b4f7a
false by default
eric-maynard 29a15b8
fixes per review
eric-maynard 82db415
autolint
eric-maynard 12caca5
more fixes
eric-maynard e08d47b
DRY
eric-maynard 7473d71
revert small change for a better error
eric-maynard 52a6be8
integration test
eric-maynard d2d4b08
extra test
eric-maynard 4839287
autolint
eric-maynard 6bfaa6c
stable
eric-maynard 1768407
wip
eric-maynard 517f407
rework subtypes a bit
eric-maynard e1e0ae2
stable again
eric-maynard 744359e
autolint
eric-maynard 6d2aa57
resolve conflict
eric-maynard 5ed7d57
apply new lint rule
eric-maynard d9bd1fc
errorprone again
eric-maynard 4d32ccd
adjustments per review
eric-maynard 960efbb
update golden files
eric-maynard 267c6a2
add another test
eric-maynard 48587d7
clean up logic in PolarisAdminService
eric-maynard f5d78aa
autolint
eric-maynard 2dcad61
more fixes per review
eric-maynard 6dddcb3
format
eric-maynard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
integration-tests/src/main/java/org/apache/polaris/service/it/env/GenericTableApi.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.polaris.service.it.env; | ||
|
|
||
| import static jakarta.ws.rs.core.Response.Status.NO_CONTENT; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import jakarta.ws.rs.client.Client; | ||
| import jakarta.ws.rs.client.Entity; | ||
| import jakarta.ws.rs.core.Response; | ||
| import java.net.URI; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import org.apache.iceberg.catalog.Namespace; | ||
| import org.apache.iceberg.catalog.TableIdentifier; | ||
| import org.apache.iceberg.rest.RESTUtil; | ||
| import org.apache.polaris.service.types.CreateGenericTableRequest; | ||
| import org.apache.polaris.service.types.GenericTable; | ||
| import org.apache.polaris.service.types.ListGenericTablesResponse; | ||
| import org.apache.polaris.service.types.LoadGenericTableResponse; | ||
|
|
||
| /** | ||
| * A simple, non-exhaustive set of helper methods for accessing the generic tables REST API | ||
| * | ||
| * @see PolarisClient#genericTableApi(ClientCredentials) | ||
| */ | ||
| public class GenericTableApi extends RestApi { | ||
| GenericTableApi(Client client, PolarisApiEndpoints endpoints, String authToken, URI uri) { | ||
| super(client, endpoints, authToken, uri); | ||
| } | ||
|
|
||
| public void purge(String catalog, Namespace ns) { | ||
| listGenericTables(catalog, ns).forEach(t -> dropGenericTable(catalog, t)); | ||
| } | ||
|
|
||
| public List<TableIdentifier> listGenericTables(String catalog, Namespace namespace) { | ||
| String ns = RESTUtil.encodeNamespace(namespace); | ||
| try (Response res = | ||
| request("polaris/v1/{cat}/namespaces/{ns}/generic-tables", Map.of("cat", catalog, "ns", ns)) | ||
| .get()) { | ||
| assertThat(res.getStatus()).isEqualTo(Response.Status.OK.getStatusCode()); | ||
| return res.readEntity(ListGenericTablesResponse.class).getIdentifiers().stream().toList(); | ||
| } | ||
| } | ||
|
|
||
| public void dropGenericTable(String catalog, TableIdentifier id) { | ||
| String ns = RESTUtil.encodeNamespace(id.namespace()); | ||
| try (Response res = | ||
| request( | ||
| "polaris/v1/{cat}/namespaces/{ns}/generic-tables/{table}", | ||
| Map.of("cat", catalog, "table", id.name(), "ns", ns)) | ||
| .delete()) { | ||
| assertThat(res.getStatus()).isEqualTo(NO_CONTENT.getStatusCode()); | ||
| } | ||
| } | ||
|
|
||
| public GenericTable getGenericTable(String catalog, TableIdentifier id) { | ||
| String ns = RESTUtil.encodeNamespace(id.namespace()); | ||
| try (Response res = | ||
| request( | ||
| "polaris/v1/{cat}/namespaces/{ns}/generic-tables/{table}", | ||
| Map.of("cat", catalog, "table", id.name(), "ns", ns)) | ||
| .get()) { | ||
| return res.readEntity(LoadGenericTableResponse.class).getTable(); | ||
| } | ||
| } | ||
|
|
||
| public GenericTable createGenericTable( | ||
| String catalog, TableIdentifier id, String format, Map<String, String> properties) { | ||
| String ns = RESTUtil.encodeNamespace(id.namespace()); | ||
| try (Response res = | ||
| request( | ||
| "polaris/v1/{cat}/namespaces/{ns}/generic-tables/", | ||
| Map.of("cat", catalog, "ns", ns)) | ||
| .post( | ||
| Entity.json(new CreateGenericTableRequest(id.name(), format, "doc", properties)))) { | ||
| return res.readEntity(LoadGenericTableResponse.class).getTable(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can init a PolarisResourcePaths instance with catalog and then directly call genericTables methods to get the request path, this is also how client used to generate the path also, then we don't have to hard code the path.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same pattern I found in CatalogApi, which seems fine for a test. This way, if the paths change the test will show a regression even if
PolarisResourcePathsis also changed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, i think it is fine to have this for test.