From 380c4651fc711527f4e60821a841c2f01f8507de Mon Sep 17 00:00:00 2001 From: Eduard Tudenhoefner Date: Wed, 4 Oct 2023 17:34:42 +0200 Subject: [PATCH] improvements --- .../iceberg/rest/RESTSessionCatalog.java | 2 +- open-api/rest-catalog-open-api.py | 10 +++++-- open-api/rest-catalog-open-api.yaml | 29 ++++++++++++++----- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java b/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java index 80fca4806f84..72fd342f6852 100644 --- a/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java +++ b/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java @@ -1233,7 +1233,7 @@ private View replace(LoadViewResponse response) { request, LoadViewResponse.class, headers(context), - ErrorHandlers.viewErrorHandler()); + ErrorHandlers.viewCommitHandler()); return viewFromResponse(viewResponse); } diff --git a/open-api/rest-catalog-open-api.py b/open-api/rest-catalog-open-api.py index f92669a2ed28..b50de6959985 100644 --- a/open-api/rest-catalog-open-api.py +++ b/open-api/rest-catalog-open-api.py @@ -666,13 +666,14 @@ class TableMetadata(BaseModel): class ViewMetadata(BaseModel): + view_uuid: str = Field(..., alias='view-uuid') format_version: int = Field(..., alias='format-version', ge=1, le=1) location: str current_version_id: int = Field(..., alias='current-version-id') versions: List[ViewVersion] version_log: List[ViewHistoryEntry] = Field(..., alias='version-log') schemas: List[Schema] - properties: Dict[str, str] + properties: Optional[Dict[str, str]] = None class AddSchemaUpdate(BaseUpdate): @@ -706,6 +707,7 @@ class TableUpdate(BaseModel): class ViewUpdate(BaseModel): __root__: Union[ + AssignUUIDUpdate, UpgradeFormatVersionUpdate, AddSchemaUpdate, SetLocationUpdate, @@ -786,7 +788,10 @@ class CreateTableRequest(BaseModel): class CreateViewRequest(BaseModel): name: str - metadata: ViewMetadata + location: Optional[str] = None + schema_: Schema = Field(..., alias='schema') + view_version: ViewVersion = Field(..., alias='view-version') + properties: Dict[str, str] class LoadViewResult(BaseModel): @@ -863,4 +868,5 @@ class ReportMetricsRequest(ScanReport): ViewMetadata.update_forward_refs() AddSchemaUpdate.update_forward_refs() CreateTableRequest.update_forward_refs() +CreateViewRequest.update_forward_refs() ReportMetricsRequest2.update_forward_refs() diff --git a/open-api/rest-catalog-open-api.yaml b/open-api/rest-catalog-open-api.yaml index 19152f13fb35..383af60ea58d 100644 --- a/open-api/rest-catalog-open-api.yaml +++ b/open-api/rest-catalog-open-api.yaml @@ -884,7 +884,7 @@ paths: 406: $ref: '#/components/responses/UnsupportedOperationResponse' 409: - description: Conflict - The target table identifier to rename to already exists + description: Conflict - The target identifier to rename to already exists as a table or view content: application/json: schema: @@ -1153,7 +1153,7 @@ paths: Load a view from the catalog. - The response contains both configuration and table metadata. The configuration, if non-empty is used + The response contains both configuration and view metadata. The configuration, if non-empty is used as additional configuration for the view that overrides catalog configuration. For example, this configuration may change the FileIO implementation to be used for the view. @@ -1380,7 +1380,7 @@ paths: description: Not Found - NoSuchViewException, view to rename does not exist - - NoSuchNamespaceException, The target namespace of the new table identifier does not exist + - NoSuchNamespaceException, The target namespace of the new identifier does not exist content: application/json: schema: @@ -1393,7 +1393,7 @@ paths: 406: $ref: '#/components/responses/UnsupportedOperationResponse' 409: - description: Conflict - The target view identifier to rename to already exists + description: Conflict - The target identifier to rename to already exists as a table or view content: application/json: schema: @@ -2094,14 +2094,16 @@ components: ViewMetadata: type: object required: + - view-uuid - format-version - location - current-version-id - versions - version-log - schemas - - properties properties: + view-uuid: + type: string format-version: type: integer minimum: 1 @@ -2358,6 +2360,7 @@ components: ViewUpdate: anyOf: + - $ref: '#/components/schemas/AssignUUIDUpdate' - $ref: '#/components/schemas/UpgradeFormatVersionUpdate' - $ref: '#/components/schemas/AddSchemaUpdate' - $ref: '#/components/schemas/SetLocationUpdate' @@ -2538,12 +2541,22 @@ components: type: object required: - name - - metadata + - schema + - view-version + - properties properties: name: type: string - metadata: - $ref: '#/components/schemas/ViewMetadata' + location: + type: string + schema: + $ref: '#/components/schemas/Schema' + view-version: + $ref: '#/components/schemas/ViewVersion' + properties: + type: object + additionalProperties: + type: string LoadViewResult: description: |