Skip to content

Commit

Permalink
chore(table): adjust table export endpoint (#549)
Browse files Browse the repository at this point in the history
Because:

- We need to allow users to export the table in a specified type.

This commit:

- Updates the table export endpoint accordingly.
  • Loading branch information
donch1989 authored Jan 24, 2025
1 parent d3446a9 commit c9ccd9e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 17 deletions.
7 changes: 5 additions & 2 deletions agent/agent/v1alpha/agent_public_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
24 changes: 18 additions & 6 deletions agent/agent/v1alpha/table.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
38 changes: 29 additions & 9 deletions openapi/v2/service.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand All @@ -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
Expand Down Expand Up @@ -7207,15 +7207,35 @@ 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:
type: string
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:
Expand Down

0 comments on commit c9ccd9e

Please sign in to comment.