From 064c2058f281b8410d5dd4f5fe811102264f4e2e Mon Sep 17 00:00:00 2001 From: yantian Date: Tue, 24 Dec 2024 09:24:23 +0800 Subject: [PATCH] generate table open api define --- .../rest/requests/CreateTableRequest.java | 1 + .../apache/paimon/rest/MockRESTMessage.java | 3 +- paimon-open-api/rest-catalog-open-api.yaml | 378 +++++++++++++++++- 3 files changed, 374 insertions(+), 8 deletions(-) diff --git a/paimon-core/src/main/java/org/apache/paimon/rest/requests/CreateTableRequest.java b/paimon-core/src/main/java/org/apache/paimon/rest/requests/CreateTableRequest.java index f566db3dcc6af..794dd33c465bf 100644 --- a/paimon-core/src/main/java/org/apache/paimon/rest/requests/CreateTableRequest.java +++ b/paimon-core/src/main/java/org/apache/paimon/rest/requests/CreateTableRequest.java @@ -43,6 +43,7 @@ public CreateTableRequest( @JsonProperty(FIELD_IDENTIFIER) Identifier identifier, @JsonProperty(FIELD_SCHEMA) Schema schema) { this.schema = schema; + this.identifier = identifier; } @JsonGetter(FIELD_IDENTIFIER) diff --git a/paimon-core/src/test/java/org/apache/paimon/rest/MockRESTMessage.java b/paimon-core/src/test/java/org/apache/paimon/rest/MockRESTMessage.java index 11c69187680cf..2e19ad1dceeec 100644 --- a/paimon-core/src/test/java/org/apache/paimon/rest/MockRESTMessage.java +++ b/paimon-core/src/test/java/org/apache/paimon/rest/MockRESTMessage.java @@ -123,7 +123,8 @@ public static UpdateTableRequest updateTableRequest(String fromTableName, String // remove option SchemaChange removeOption = SchemaChange.removeOption("compaction.max.file-num"); // add column - SchemaChange addColumn = SchemaChange.addColumn("col1_after", DataTypes.STRING()); + SchemaChange addColumn = + SchemaChange.addColumn("col1_after", DataTypes.ARRAY(DataTypes.STRING())); // add a column after col1 SchemaChange.Move after = SchemaChange.Move.after("col1_after", "col1"); SchemaChange addColumnAfterField = diff --git a/paimon-open-api/rest-catalog-open-api.yaml b/paimon-open-api/rest-catalog-open-api.yaml index f7f9529f53dd2..6fe66bcd2a60e 100644 --- a/paimon-open-api/rest-catalog-open-api.yaml +++ b/paimon-open-api/rest-catalog-open-api.yaml @@ -80,6 +80,118 @@ paths: $ref: '#/components/schemas/ErrorResponse' "500": description: Internal Server Error + /v1/{prefix}/databases/{database}/tables: + get: + tags: + - table + summary: List tables + operationId: listTables + parameters: + - name: prefix + in: path + required: true + schema: + type: string + - name: database + in: path + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ListTablesResponse' + "500": + description: Internal Server Error + post: + tags: + - table + summary: Create table + operationId: createTable + parameters: + - name: prefix + in: path + required: true + schema: + type: string + - name: database + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateTableRequest' + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/GetTableResponse' + "500": + description: Internal Server Error + /v1/{prefix}/databases/{database}/tables/table: + post: + tags: + - table + summary: Update table + operationId: updateTable + parameters: + - name: prefix + in: path + required: true + schema: + type: string + - name: database + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateTableRequest' + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/GetTableResponse' + "500": + description: Internal Server Error + delete: + tags: + - table + summary: Update table + operationId: dropTable + parameters: + - name: prefix + in: path + required: true + schema: + type: string + - name: database + in: path + required: true + schema: + type: string + responses: + "404": + description: Resource not found + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + "500": + description: Internal Server Error /v1/{prefix}/databases/{database}/properties: post: tags: @@ -174,6 +286,43 @@ paths: $ref: '#/components/schemas/ErrorResponse' "500": description: Internal Server Error + /v1/{prefix}/databases/{database}/tables/{table}: + get: + tags: + - table + summary: Get table + operationId: getTable + parameters: + - name: prefix + in: path + required: true + schema: + type: string + - name: database + in: path + required: true + schema: + type: string + - name: table + in: path + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ListTablesResponse' + "404": + description: Resource not found + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + "500": + description: Internal Server Error /v1/config: get: tags: @@ -200,6 +349,15 @@ components: type: object additionalProperties: type: string + CreateDatabaseResponse: + type: object + properties: + name: + type: string + options: + type: object + additionalProperties: + type: string ErrorResponse: type: object properties: @@ -212,15 +370,219 @@ components: type: array items: type: string - CreateDatabaseResponse: + CreateTableRequest: + type: object + properties: + identifier: + $ref: '#/components/schemas/Identifier' + schema: + $ref: '#/components/schemas/Schema' + DataField: type: object properties: + id: + type: integer + format: int32 name: type: string + type: + $ref: '#/components/schemas/DataType' + description: + type: string + DataType: + type: object + properties: + typeRoot: + type: string + enum: + - CHAR + - VARCHAR + - BOOLEAN + - BINARY + - VARBINARY + - DECIMAL + - TINYINT + - SMALLINT + - INTEGER + - BIGINT + - FLOAT + - DOUBLE + - DATE + - TIME_WITHOUT_TIME_ZONE + - TIMESTAMP_WITHOUT_TIME_ZONE + - TIMESTAMP_WITH_LOCAL_TIME_ZONE + - ARRAY + - MULTISET + - MAP + - ROW + nullable: + type: boolean + Identifier: + type: object + properties: + systemTable: + type: boolean + fullName: + type: string + databaseName: + type: string + tableName: + type: string + branchName: + type: string + branchNameOrDefault: + type: string + systemTableName: + type: string + escapedFullName: + type: string + objectName: + type: string + Schema: + type: object + properties: + fields: + type: array + items: + $ref: '#/components/schemas/DataField' + partitionKeys: + type: array + items: + type: string + primaryKeys: + type: array + items: + type: string options: type: object additionalProperties: type: string + comment: + type: string + GetTableResponse: + type: object + properties: + location: + type: string + schema: + $ref: '#/components/schemas/TableSchema' + TableSchema: + type: object + AddColumn: + type: object + properties: + fieldNames: + type: array + items: + type: string + dataType: + $ref: '#/components/schemas/DataType' + description: + type: string + move: + $ref: '#/components/schemas/Move' + Move: + type: object + properties: + fieldName: + type: string + referenceFieldName: + type: string + type: + type: string + enum: + - FIRST + - AFTER + - BEFORE + - LAST + RenameColumn: + type: object + properties: + fieldNames: + type: array + items: + type: string + newName: + type: string + SchemaChanges: + type: object + properties: + setOptions: + type: object + additionalProperties: + type: string + removeOptions: + type: array + items: + type: string + comment: + type: string + addColumns: + type: array + items: + $ref: '#/components/schemas/AddColumn' + renameColumns: + type: array + items: + $ref: '#/components/schemas/RenameColumn' + dropColumns: + type: array + items: + type: string + updateColumnTypes: + type: array + items: + $ref: '#/components/schemas/UpdateColumnType' + updateColumnNullabilities: + type: array + items: + $ref: '#/components/schemas/UpdateColumnNullability' + updateColumnComments: + type: array + items: + $ref: '#/components/schemas/UpdateColumnComment' + updateColumnPositions: + type: array + items: + $ref: '#/components/schemas/Move' + UpdateColumnComment: + type: object + properties: + fieldNames: + type: array + items: + type: string + newDescription: + type: string + UpdateColumnNullability: + type: object + properties: + fieldNames: + type: array + items: + type: string + newNullability: + type: boolean + UpdateColumnType: + type: object + properties: + fieldNames: + type: array + items: + type: string + newDataType: + $ref: '#/components/schemas/DataType' + keepNullability: + type: boolean + UpdateTableRequest: + type: object + properties: + fromIdentifier: + $ref: '#/components/schemas/Identifier' + toIdentifier: + $ref: '#/components/schemas/Identifier' + changes: + $ref: '#/components/schemas/SchemaChanges' AlterDatabaseRequest: type: object properties: @@ -247,18 +609,13 @@ components: type: array items: type: string - DatabaseName: - type: object - properties: - name: - type: string ListDatabasesResponse: type: object properties: databases: type: array items: - $ref: '#/components/schemas/DatabaseName' + type: string GetDatabaseResponse: type: object properties: @@ -268,6 +625,13 @@ components: type: object additionalProperties: type: string + ListTablesResponse: + type: object + properties: + tables: + type: array + items: + type: string ConfigResponse: type: object properties: