From c9ccd9e53d270d524048ccb2f4eae7f527bd4276 Mon Sep 17 00:00:00 2001 From: "Chang, Hui-Tang" Date: Fri, 24 Jan 2025 22:48:46 +0800 Subject: [PATCH] chore(table): adjust table export endpoint (#549) Because: - We need to allow users to export the table in a specified type. This commit: - Updates the table export endpoint accordingly. --- .../agent/v1alpha/agent_public_service.proto | 7 +++- agent/agent/v1alpha/table.proto | 24 +++++++++--- openapi/v2/service.swagger.yaml | 38 ++++++++++++++----- 3 files changed, 52 insertions(+), 17 deletions(-) diff --git a/agent/agent/v1alpha/agent_public_service.proto b/agent/agent/v1alpha/agent_public_service.proto index 235dcbd8..eee92f12 100644 --- a/agent/agent/v1alpha/agent_public_service.proto +++ b/agent/agent/v1alpha/agent_public_service.proto @@ -418,8 +418,11 @@ service AgentPublicService { // Export table // // Exports table data. - rpc Export(ExportRequest) returns (ExportResponse) { - option (google.api.http) = {get: "/v1alpha/namespaces/{namespace_id}/tables/{table_uid}/export"}; + rpc ExportTable(ExportTableRequest) returns (ExportTableResponse) { + option (google.api.http) = { + post: "/v1alpha/namespaces/{namespace_id}/tables/{table_uid}/export" + body: "*" + }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "Table" extensions: { diff --git a/agent/agent/v1alpha/table.proto b/agent/agent/v1alpha/table.proto index 58405b22..6990c0b4 100644 --- a/agent/agent/v1alpha/table.proto +++ b/agent/agent/v1alpha/table.proto @@ -456,20 +456,32 @@ message MoveRowsRequest { // MoveRowsResponse is an empty response for moving multiple rows. message MoveRowsResponse {} -// ExportRequest represents a request to export table data. -message ExportRequest { +// ExportType represents the type to export the data in. +enum ExportType { + // The type is not specified. + EXPORT_TYPE_UNSPECIFIED = 0; + + // The type is CSV. + EXPORT_TYPE_CSV = 1; + + // The type is Parquet. + EXPORT_TYPE_PARQUET = 2; +} + +// ExportTableRequest represents a request to export table data. +message ExportTableRequest { // The ID of the namespace that owns the table. string namespace_id = 1 [(google.api.field_behavior) = REQUIRED]; // The UID of the table to export. string table_uid = 2 [(google.api.field_behavior) = REQUIRED]; - // The format to export the data in (csv, parquet). - string type = 3 [(google.api.field_behavior) = REQUIRED]; + // The type to export the data in. + ExportType type = 3 [(google.api.field_behavior) = REQUIRED]; } -// ExportResponse is an empty response for exporting table data. -message ExportResponse { +// ExportTableResponse is an empty response for exporting table data. +message ExportTableResponse { // The exported data. bytes data = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; } diff --git a/openapi/v2/service.swagger.yaml b/openapi/v2/service.swagger.yaml index 82e004ef..f19974db 100644 --- a/openapi/v2/service.swagger.yaml +++ b/openapi/v2/service.swagger.yaml @@ -915,15 +915,15 @@ paths: - Table x-stage: alpha /v1alpha/namespaces/{namespaceId}/tables/{tableUid}/export: - get: + post: summary: Export table description: Exports table data. - operationId: AgentPublicService_Export + operationId: AgentPublicService_ExportTable responses: "200": description: A successful response. schema: - $ref: '#/definitions/ExportResponse' + $ref: '#/definitions/ExportTableResponse' "401": description: Returned when the client credentials are not valid. schema: {} @@ -942,11 +942,11 @@ paths: in: path required: true type: string - - name: type - description: The format to export the data in (csv, parquet). - in: query + - name: body + in: body required: true - type: string + schema: + $ref: '#/definitions/ExportTableBody' tags: - Table x-stage: alpha @@ -7207,7 +7207,17 @@ definitions: description: JSON schema describing the component event examples. readOnly: true description: EventSpecification describes the JSON schema of component event setup and examples. - ExportResponse: + ExportTableBody: + type: object + properties: + type: + description: The type to export the data in. + allOf: + - $ref: '#/definitions/ExportType' + description: ExportTableRequest represents a request to export table data. + required: + - type + ExportTableResponse: type: object properties: data: @@ -7215,7 +7225,17 @@ definitions: format: byte description: The exported data. readOnly: true - description: ExportResponse is an empty response for exporting table data. + description: ExportTableResponse is an empty response for exporting table data. + ExportType: + type: string + enum: + - EXPORT_TYPE_CSV + - EXPORT_TYPE_PARQUET + description: |- + ExportType represents the type to export the data in. + + - EXPORT_TYPE_CSV: The type is CSV. + - EXPORT_TYPE_PARQUET: The type is Parquet. File: type: object properties: