From 678fbdfc016646062f3b61a8e3cf6b81efb51bb0 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 7 Jul 2024 18:39:45 +0500 Subject: [PATCH 01/26] added sql query specification Signed-off-by: Tokesh --- spec/namespaces/sql.yaml | 53 +++++++++++++++++++++++++++++++++++ spec/schemas/sql._common.yaml | 40 ++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 spec/namespaces/sql.yaml create mode 100644 spec/schemas/sql._common.yaml diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml new file mode 100644 index 000000000..1de7a6915 --- /dev/null +++ b/spec/namespaces/sql.yaml @@ -0,0 +1,53 @@ +openapi: 3.1.0 +info: + title: OpenSearch SQL API + description: OpenSearch SQL API + version: 1.0.0 +paths: + /_plugins/_sql: + post: + operationId: sql.query.0 + x-operation-group: sql.query + x-version-added: '1.0' + description: Sends an SQL/PPL query to the SQL plugin. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ + parameters: + - $ref: '#/components/parameters/sql.query::format' + - $ref: '#/components/parameters/sql.query::sanitize' + requestBody: + $ref: '#/components/requestBodies/sql.query' + responses: + '200': + $ref: '#/components/responses/sql.query@200' +components: + parameters: + sql.query::format: + name: format + in: query + description: A short version of the Accept header, e.g. json, yaml. + schema: + type: string + description: A short version of the Accept header, e.g. json, yaml. + sql.query::sanitize: + name: sanitize + in: query + description: Specifies whether to escape special characters in the results + schema: + type: boolean + default: true + description: A short version of the Accept header, e.g. json, yaml. + requestBodies: + sql.query: + content: + application/json: + schema: + $ref: '../schemas/sql._common.yaml#/components/schemas/SqlQuery' + required: true + responses: + sql.query@200: + description: '' + content: + application/json: + schema: + $ref: '../schemas/sql._common.yaml#/components/schemas/SqlResponse' diff --git a/spec/schemas/sql._common.yaml b/spec/schemas/sql._common.yaml new file mode 100644 index 000000000..6b511cfc5 --- /dev/null +++ b/spec/schemas/sql._common.yaml @@ -0,0 +1,40 @@ +openapi: 3.1.0 +info: + title: Schemas of sql._common category. + description: Schemas of sql._common category. + version: 1.0.0 +paths: {} +components: + schemas: + SqlQuery: # Can we name it just Query? + type: object + properties: + query: + type: string + filter: + type: object + fetch_size: + type: integer + SqlResponse: + type: object + properties: + schema: + type: array + items: + type: object + data_rows: + type: array + items: # this is 2d array. Is it normal to write like this? Or perhaps we need to define DataRows structure at the bottom? + type: array + items: + type: object + total: + type: integer + size: + type: integer + status: + type: string + # DataRows: + # type: array + # items: object + \ No newline at end of file From 36b6c489c7e080148fd2921fec2747acfbe11b20 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 7 Jul 2024 18:46:02 +0500 Subject: [PATCH 02/26] lint of query params Signed-off-by: Tokesh --- spec/namespaces/sql.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index 1de7a6915..960de674b 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -13,8 +13,8 @@ paths: externalDocs: url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ parameters: - - $ref: '#/components/parameters/sql.query::format' - - $ref: '#/components/parameters/sql.query::sanitize' + - $ref: '#/components/parameters/sql.query::query.format' + - $ref: '#/components/parameters/sql.query::query.sanitize' requestBody: $ref: '#/components/requestBodies/sql.query' responses: @@ -22,14 +22,14 @@ paths: $ref: '#/components/responses/sql.query@200' components: parameters: - sql.query::format: + sql.query::query.format: name: format in: query description: A short version of the Accept header, e.g. json, yaml. schema: type: string description: A short version of the Accept header, e.g. json, yaml. - sql.query::sanitize: + sql.query::query.sanitize: name: sanitize in: query description: Specifies whether to escape special characters in the results From 2a61bedf84d4ba20cc270f20c97ccb0fcefe21af Mon Sep 17 00:00:00 2001 From: Tokesh Date: Mon, 8 Jul 2024 19:17:18 +0500 Subject: [PATCH 03/26] added explain, close and stats API specs Signed-off-by: Tokesh --- spec/namespaces/sql.yaml | 144 +++++++++++++++++++++++++++++++++- spec/schemas/sql._common.yaml | 71 +++++++++++++++-- 2 files changed, 209 insertions(+), 6 deletions(-) diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index 960de674b..dfb54c59f 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -20,6 +20,67 @@ paths: responses: '200': $ref: '#/components/responses/sql.query@200' + /_plugins/_sql/_explain: + post: + operationId: sql.explain.0 + x-operation-group: sql.explain + x-version-added: '1.0' + description: Shows how a query is executed against OpenSearch + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ + parameters: + - $ref: '#/components/parameters/sql.explain::query.format' + - $ref: '#/components/parameters/sql.explain::query.sanitize' + requestBody: + $ref: '#/components/requestBodies/sql.explain' + responses: + '200': + $ref: '#/components/responses/sql.explain@200' + /_plugins/_sql/close: + post: + operationId: sql.close.0 + x-operation-group: sql.close + x-version-added: '1.0' + description: To explicitly clear the cursor context + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ + parameters: + - $ref: '#/components/parameters/sql.close::query.format' + - $ref: '#/components/parameters/sql.close::query.sanitize' + requestBody: + $ref: '#/components/requestBodies/sql.close' + responses: + '200': + $ref: '#/components/responses/sql.close@200' + /_plugins/_sql/stats: + get: + operationId: sql.stats.0 + x-operation-group: sql.stats + x-version-added: '1.0' + description: By a stats endpoint, you are able to collect metrics for the plugin within the interval. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/monitoring/ + parameters: + - $ref: '#/components/parameters/sql.stats::query.format' + - $ref: '#/components/parameters/sql.stats::query.sanitize' + responses: + '200': + $ref: '#/components/responses/sql.stats@200' + post: + operationId: sql.query.0 + x-operation-group: sql.query + x-version-added: '1.0' + description: By a stats endpoint, you are able to collect metrics for the plugin within the interval. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/monitoring/ + parameters: + - $ref: '#/components/parameters/sql.stats::query.format' + - $ref: '#/components/parameters/sql.stats::query.sanitize' + requestBody: + $ref: '#/components/requestBodies/sql.stats' + responses: + '200': + $ref: '#/components/responses/sql.stats@200' components: parameters: sql.query::query.format: @@ -36,7 +97,52 @@ components: schema: type: boolean default: true + description: Specifies whether to escape special characters in the results + sql.explain::query.format: + name: format + in: query + description: A short version of the Accept header, e.g. json, yaml. + schema: + type: string + description: A short version of the Accept header, e.g. json, yaml. + sql.explain::query.sanitize: + name: sanitize + in: query + description: Specifies whether to escape special characters in the results + schema: + type: boolean + default: true + description: Specifies whether to escape special characters in the results + sql.close::query.format: + name: format + in: query + description: A short version of the Accept header, e.g. json, yaml. + schema: + type: string + description: A short version of the Accept header, e.g. json, yaml. + sql.close::query.sanitize: + name: sanitize + in: query + description: Specifies whether to escape special characters in the results + schema: + type: boolean + default: true + description: Specifies whether to escape special characters in the results + sql.stats::query.format: + name: format + in: query + description: A short version of the Accept header, e.g. json, yaml. + schema: + type: string description: A short version of the Accept header, e.g. json, yaml. + sql.stats::query.sanitize: + name: sanitize + in: query + description: Specifies whether to escape special characters in the results + schema: + type: boolean + default: true + description: Specifies whether to escape special characters in the results requestBodies: sql.query: content: @@ -44,10 +150,46 @@ components: schema: $ref: '../schemas/sql._common.yaml#/components/schemas/SqlQuery' required: true + sql.explain: + content: + application/json: + schema: + $ref: '../schemas/sql._common.yaml#/components/schemas/SqlExplain' + required: true + sql.close: + content: + application/json: + schema: + $ref: '../schemas/sql._common.yaml#/components/schemas/SqlClose' + required: true + sql.stats: + content: + application/json: + schema: + $ref: '../schemas/sql._common.yaml#/components/schemas/SqlStats' + required: true responses: sql.query@200: description: '' content: application/json: schema: - $ref: '../schemas/sql._common.yaml#/components/schemas/SqlResponse' + $ref: '../schemas/sql._common.yaml#/components/schemas/SqlQueryResponse' + sql.explain@200: + content: + application/json: + schema: + $ref: '../schemas/sql._common.yaml#/components/schemas/SqlExplainResponse' + required: true + sql.close@200: + content: + application/json: + schema: + $ref: '../schemas/sql._common.yaml#/components/schemas/SqlCloseResponse' + required: true + sql.stats@200: + content: + application/json: + schema: + $ref: '../schemas/sql._common.yaml#/components/schemas/SqlStatsResponse' + required: true \ No newline at end of file diff --git a/spec/schemas/sql._common.yaml b/spec/schemas/sql._common.yaml index 6b511cfc5..039a032ee 100644 --- a/spec/schemas/sql._common.yaml +++ b/spec/schemas/sql._common.yaml @@ -15,7 +15,7 @@ components: type: object fetch_size: type: integer - SqlResponse: + SqlQueryResponse: type: object properties: schema: @@ -34,7 +34,68 @@ components: type: integer status: type: string - # DataRows: - # type: array - # items: object - \ No newline at end of file + SqlExplain: + type: object + properties: + query: + type: string + filter: + type: object + fetch_size: + type: integer + SqlExplainResponse: + type: object + properties: + root: + $ref: '#/components/schemas/Explain' + Explain: + type: object + properties: + name: + type: string + description: + type: object + children: + type: items + items: + $ref: '#/components/schemas/Explain' + SqlClose: + type: object + properties: + cursor: + type: string + SqlCloseResponse: + type: object + properties: + succeeded: + type: boolean + SqlStats: + type: object + properties: + start_time: + type: string + end_time: + type: object + cluster_name: + type: object + index: + type: object + query: + type: object + user: + type: object + execution_time: + type: object + SqlStatsResponse: + type: object + properties: + request_total: + type: integer + request_count: + type: integer + failed_request_count_syserr: + type: integer + failed_request_count_cuserr: + type: integer + failed_request_count_cb: + type: integer \ No newline at end of file From 6af83168468a00ff8c0a70a852b36564a0c0ef9e Mon Sep 17 00:00:00 2001 From: Tokesh Date: Mon, 8 Jul 2024 19:19:37 +0500 Subject: [PATCH 04/26] small fix of x-operation group Signed-off-by: Tokesh --- spec/namespaces/sql.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index dfb54c59f..5885bc6f5 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -67,8 +67,8 @@ paths: '200': $ref: '#/components/responses/sql.stats@200' post: - operationId: sql.query.0 - x-operation-group: sql.query + operationId: sql.stats.1 + x-operation-group: sql.stats x-version-added: '1.0' description: By a stats endpoint, you are able to collect metrics for the plugin within the interval. externalDocs: From 108d0a05f0d82fbdf37067710972a930470335bb Mon Sep 17 00:00:00 2001 From: Tokesh Date: Mon, 8 Jul 2024 19:33:53 +0500 Subject: [PATCH 05/26] fixing lint errors Signed-off-by: Tokesh --- spec/namespaces/sql.yaml | 53 ++++++++++++++++++++++++----------- spec/schemas/sql._common.yaml | 2 +- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index 5885bc6f5..559f67e5d 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -25,7 +25,7 @@ paths: operationId: sql.explain.0 x-operation-group: sql.explain x-version-added: '1.0' - description: Shows how a query is executed against OpenSearch + description: Shows how a query is executed against OpenSearch. externalDocs: url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ parameters: @@ -41,7 +41,7 @@ paths: operationId: sql.close.0 x-operation-group: sql.close x-version-added: '1.0' - description: To explicitly clear the cursor context + description: To explicitly clear the cursor context. externalDocs: url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ parameters: @@ -54,33 +54,33 @@ paths: $ref: '#/components/responses/sql.close@200' /_plugins/_sql/stats: get: - operationId: sql.stats.0 + operationId: sql.get_stats.0 x-operation-group: sql.stats x-version-added: '1.0' description: By a stats endpoint, you are able to collect metrics for the plugin within the interval. externalDocs: url: https://opensearch.org/docs/latest/search-plugins/sql/monitoring/ parameters: - - $ref: '#/components/parameters/sql.stats::query.format' - - $ref: '#/components/parameters/sql.stats::query.sanitize' + - $ref: '#/components/parameters/sql.get_stats::query.format' + - $ref: '#/components/parameters/sql.get_stats::query.sanitize' responses: '200': - $ref: '#/components/responses/sql.stats@200' + $ref: '#/components/responses/sql.get_stats@200' post: - operationId: sql.stats.1 - x-operation-group: sql.stats + operationId: sql.post_stats.1 + x-operation-group: sql.post_stats x-version-added: '1.0' description: By a stats endpoint, you are able to collect metrics for the plugin within the interval. externalDocs: url: https://opensearch.org/docs/latest/search-plugins/sql/monitoring/ parameters: - - $ref: '#/components/parameters/sql.stats::query.format' - - $ref: '#/components/parameters/sql.stats::query.sanitize' + - $ref: '#/components/parameters/sql.post_stats::query.format' + - $ref: '#/components/parameters/sql.post_stats::query.sanitize' requestBody: - $ref: '#/components/requestBodies/sql.stats' + $ref: '#/components/requestBodies/sql.post_stats' responses: '200': - $ref: '#/components/responses/sql.stats@200' + $ref: '#/components/responses/sql.post_stats@200' components: parameters: sql.query::query.format: @@ -128,14 +128,29 @@ components: type: boolean default: true description: Specifies whether to escape special characters in the results - sql.stats::query.format: + sql.get_stats::query.format: name: format in: query description: A short version of the Accept header, e.g. json, yaml. schema: type: string description: A short version of the Accept header, e.g. json, yaml. - sql.stats::query.sanitize: + sql.get_stats::query.sanitize: + name: sanitize + in: query + description: Specifies whether to escape special characters in the results + schema: + type: boolean + default: true + description: Specifies whether to escape special characters in the results + sql.post_stats::query.format: + name: format + in: query + description: A short version of the Accept header, e.g. json, yaml. + schema: + type: string + description: A short version of the Accept header, e.g. json, yaml. + sql.post_stats::query.sanitize: name: sanitize in: query description: Specifies whether to escape special characters in the results @@ -162,7 +177,7 @@ components: schema: $ref: '../schemas/sql._common.yaml#/components/schemas/SqlClose' required: true - sql.stats: + sql.post_stats: content: application/json: schema: @@ -187,7 +202,13 @@ components: schema: $ref: '../schemas/sql._common.yaml#/components/schemas/SqlCloseResponse' required: true - sql.stats@200: + sql.get_stats@200: + content: + application/json: + schema: + $ref: '../schemas/sql._common.yaml#/components/schemas/SqlStatsResponse' + required: true + sql.post_stats@200: content: application/json: schema: diff --git a/spec/schemas/sql._common.yaml b/spec/schemas/sql._common.yaml index 039a032ee..878bc3928 100644 --- a/spec/schemas/sql._common.yaml +++ b/spec/schemas/sql._common.yaml @@ -56,7 +56,7 @@ components: description: type: object children: - type: items + type: array items: $ref: '#/components/schemas/Explain' SqlClose: From a0965bcd65fd4dfc08c9600ef63f9b42eb32cd98 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Mon, 8 Jul 2024 19:38:21 +0500 Subject: [PATCH 06/26] small fix of operation group Signed-off-by: Tokesh --- spec/namespaces/sql.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index 559f67e5d..6d92f0be7 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -55,7 +55,7 @@ paths: /_plugins/_sql/stats: get: operationId: sql.get_stats.0 - x-operation-group: sql.stats + x-operation-group: sql.get_stats x-version-added: '1.0' description: By a stats endpoint, you are able to collect metrics for the plugin within the interval. externalDocs: @@ -65,7 +65,7 @@ paths: - $ref: '#/components/parameters/sql.get_stats::query.sanitize' responses: '200': - $ref: '#/components/responses/sql.get_stats@200' + $ref: '#/components/responses/sql.stats@200' post: operationId: sql.post_stats.1 x-operation-group: sql.post_stats @@ -80,7 +80,7 @@ paths: $ref: '#/components/requestBodies/sql.post_stats' responses: '200': - $ref: '#/components/responses/sql.post_stats@200' + $ref: '#/components/responses/sql.stats@200' components: parameters: sql.query::query.format: From df6c0ff6b942a0d4dab5a5b0b9f7f04e15b9d9e0 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Mon, 8 Jul 2024 19:40:33 +0500 Subject: [PATCH 07/26] Revert "fix operation xgroup" This reverts commit e6958b363dd00b5702dba4159985b935d7360e62. Signed-off-by: Tokesh --- spec/namespaces/sql.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index 6d92f0be7..559f67e5d 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -55,7 +55,7 @@ paths: /_plugins/_sql/stats: get: operationId: sql.get_stats.0 - x-operation-group: sql.get_stats + x-operation-group: sql.stats x-version-added: '1.0' description: By a stats endpoint, you are able to collect metrics for the plugin within the interval. externalDocs: @@ -65,7 +65,7 @@ paths: - $ref: '#/components/parameters/sql.get_stats::query.sanitize' responses: '200': - $ref: '#/components/responses/sql.stats@200' + $ref: '#/components/responses/sql.get_stats@200' post: operationId: sql.post_stats.1 x-operation-group: sql.post_stats @@ -80,7 +80,7 @@ paths: $ref: '#/components/requestBodies/sql.post_stats' responses: '200': - $ref: '#/components/responses/sql.stats@200' + $ref: '#/components/responses/sql.post_stats@200' components: parameters: sql.query::query.format: From 225447d2bc8280ec8fa2c4db6f15e8e9d9ce6c10 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Mon, 8 Jul 2024 19:42:51 +0500 Subject: [PATCH 08/26] fix response body Signed-off-by: Tokesh --- spec/namespaces/sql.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index 559f67e5d..6f16a0b87 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -55,7 +55,7 @@ paths: /_plugins/_sql/stats: get: operationId: sql.get_stats.0 - x-operation-group: sql.stats + x-operation-group: sql.get_stats x-version-added: '1.0' description: By a stats endpoint, you are able to collect metrics for the plugin within the interval. externalDocs: @@ -202,6 +202,12 @@ components: schema: $ref: '../schemas/sql._common.yaml#/components/schemas/SqlCloseResponse' required: true + sql.stats@200: + content: + application/json: + schema: + $ref: '../schemas/sql._common.yaml#/components/schemas/SqlStatsResponse' + required: true sql.get_stats@200: content: application/json: From aa51113f19931b6cc1c2fe45beba96e829d44f2f Mon Sep 17 00:00:00 2001 From: Tokesh Date: Mon, 8 Jul 2024 19:45:38 +0500 Subject: [PATCH 09/26] response body not passing linter Signed-off-by: Tokesh --- spec/namespaces/sql.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index 6f16a0b87..602e96975 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -65,7 +65,7 @@ paths: - $ref: '#/components/parameters/sql.get_stats::query.sanitize' responses: '200': - $ref: '#/components/responses/sql.get_stats@200' + $ref: '#/components/responses/sql.stats@200' post: operationId: sql.post_stats.1 x-operation-group: sql.post_stats @@ -80,7 +80,7 @@ paths: $ref: '#/components/requestBodies/sql.post_stats' responses: '200': - $ref: '#/components/responses/sql.post_stats@200' + $ref: '#/components/responses/sql.stats@200' components: parameters: sql.query::query.format: From 68752e215ee93862bcefcc7807a3ab723ad3fb75 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Mon, 8 Jul 2024 19:47:03 +0500 Subject: [PATCH 10/26] response body Signed-off-by: Tokesh --- spec/namespaces/sql.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index 602e96975..6f16a0b87 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -65,7 +65,7 @@ paths: - $ref: '#/components/parameters/sql.get_stats::query.sanitize' responses: '200': - $ref: '#/components/responses/sql.stats@200' + $ref: '#/components/responses/sql.get_stats@200' post: operationId: sql.post_stats.1 x-operation-group: sql.post_stats @@ -80,7 +80,7 @@ paths: $ref: '#/components/requestBodies/sql.post_stats' responses: '200': - $ref: '#/components/responses/sql.stats@200' + $ref: '#/components/responses/sql.post_stats@200' components: parameters: sql.query::query.format: From 374e0e6fa8001088f2696216850df28bc725294b Mon Sep 17 00:00:00 2001 From: Tokesh Date: Mon, 8 Jul 2024 19:49:56 +0500 Subject: [PATCH 11/26] deleting unnecessary response body Signed-off-by: Tokesh --- spec/namespaces/sql.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index 6f16a0b87..c9e8fe36d 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -202,12 +202,6 @@ components: schema: $ref: '../schemas/sql._common.yaml#/components/schemas/SqlCloseResponse' required: true - sql.stats@200: - content: - application/json: - schema: - $ref: '../schemas/sql._common.yaml#/components/schemas/SqlStatsResponse' - required: true sql.get_stats@200: content: application/json: From 73974e77859592da940261b2121fd7f3c2b5df99 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Mon, 8 Jul 2024 20:42:55 +0500 Subject: [PATCH 12/26] adding first test for SQL query api Signed-off-by: Tokesh --- .env | 3 +++ tests/sql/query.yaml | 30 ++++++++++++++++++++++++++++++ tools/src/OpenSearchHttpClient.ts | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 .env create mode 100644 tests/sql/query.yaml diff --git a/.env b/.env new file mode 100644 index 000000000..bc54e8d67 --- /dev/null +++ b/.env @@ -0,0 +1,3 @@ +OPENSEARCH_URL=http://localhost:9201 +OPENSEARCH_USERNAME=admin +OPENSEARCH_PASSWORD=Counter2727! \ No newline at end of file diff --git a/tests/sql/query.yaml b/tests/sql/query.yaml new file mode 100644 index 000000000..6765ab430 --- /dev/null +++ b/tests/sql/query.yaml @@ -0,0 +1,30 @@ +$schema: ../../json_schemas/test_story.schema.yaml + +description: Test send SQL query to index. + +epilogues: + - path: /_plugins/_sql + method: POST + request_body: + payload: + query: SELECT name FROM books1 + status: [200] +chapters: + - synopsis: Create an index named `books` with mappings and settings. + path: /{index} + method: PUT + parameters: + index: books1 + request_body: + payload: + mappings: + properties: + name: + type: keyword + age: + type: integer + settings: + number_of_shards: 5 + number_of_replicas: 2 + response: + status: 200 \ No newline at end of file diff --git a/tools/src/OpenSearchHttpClient.ts b/tools/src/OpenSearchHttpClient.ts index 7ffcb1421..605cbe639 100644 --- a/tools/src/OpenSearchHttpClient.ts +++ b/tools/src/OpenSearchHttpClient.ts @@ -12,7 +12,7 @@ import axios, { type AxiosInstance, type AxiosRequestConfig, type AxiosResponse, import * as https from 'node:https' import { sleep } from './helpers' -const DEFAULT_URL = 'https://localhost:9200' +const DEFAULT_URL = 'http://localhost:9201' const DEFAULT_USER = 'admin' const DEFAULT_INSECURE = false From a615da8f5ecb9c478d1aa29c39c3ef114d4fa956 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Mon, 8 Jul 2024 20:45:14 +0500 Subject: [PATCH 13/26] deleting local parameters for testing Signed-off-by: Tokesh --- .env | 3 --- tools/src/OpenSearchHttpClient.ts | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index bc54e8d67..000000000 --- a/.env +++ /dev/null @@ -1,3 +0,0 @@ -OPENSEARCH_URL=http://localhost:9201 -OPENSEARCH_USERNAME=admin -OPENSEARCH_PASSWORD=Counter2727! \ No newline at end of file diff --git a/tools/src/OpenSearchHttpClient.ts b/tools/src/OpenSearchHttpClient.ts index 605cbe639..7ffcb1421 100644 --- a/tools/src/OpenSearchHttpClient.ts +++ b/tools/src/OpenSearchHttpClient.ts @@ -12,7 +12,7 @@ import axios, { type AxiosInstance, type AxiosRequestConfig, type AxiosResponse, import * as https from 'node:https' import { sleep } from './helpers' -const DEFAULT_URL = 'http://localhost:9201' +const DEFAULT_URL = 'https://localhost:9200' const DEFAULT_USER = 'admin' const DEFAULT_INSECURE = false From cb81586309bceace258d02fd928b298375737d64 Mon Sep 17 00:00:00 2001 From: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> Date: Sun, 21 Jul 2024 22:16:37 +0500 Subject: [PATCH 14/26] adding tests for sql namespace Signed-off-by: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> --- tests/sql/close.yaml | 35 +++++++++++++++++++++++++++++++++++ tests/sql/explain.yaml | 23 +++++++++++++++++++++++ tests/sql/query.yaml | 37 +++++++++++++++---------------------- tests/sql/stats.yaml | 24 ++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 22 deletions(-) create mode 100644 tests/sql/close.yaml create mode 100644 tests/sql/explain.yaml create mode 100644 tests/sql/stats.yaml diff --git a/tests/sql/close.yaml b/tests/sql/close.yaml new file mode 100644 index 000000000..4f6fd87cf --- /dev/null +++ b/tests/sql/close.yaml @@ -0,0 +1,35 @@ +$schema: ../../json_schemas/test_story.schema.yaml + +description: Test to explicitly clear the cursor context + +prologues: + - path: /{index} + method: PUT + parameters: + index: books + request_body: + payload: {} +epilogues: + - path: /books + method: DELETE + status: [200, 404] +chapters: + - synopsis: Get SQL query + id: query_sql + path: /_plugins/_sql + method: POST + request_body: + payload: + query: SELECT * FROM books + fetch_size: 1 + output: + cursor: "payload.cursor" + status: [200] + - synopsis: Close cursor + path: /_plugins/_sql/close + method: POST + request_body: + payload: + cursor: + - ${query_sql.cursor} + status: [200] \ No newline at end of file diff --git a/tests/sql/explain.yaml b/tests/sql/explain.yaml new file mode 100644 index 000000000..9a13bbad2 --- /dev/null +++ b/tests/sql/explain.yaml @@ -0,0 +1,23 @@ +$schema: ../../json_schemas/test_story.schema.yaml + +description: Test how a query is executed against OpenSearch. + +prologues: + - path: /{index} + method: PUT + parameters: + index: books + request_body: + payload: {} +epilogues: + - path: /books + method: DELETE + status: [200, 404] +chapters: + - synopsis: Get explain of SQL Query + path: /_plugins/_sql/explain + method: POST + request_body: + payload: + query: SELECT * FROM books + status: [200] diff --git a/tests/sql/query.yaml b/tests/sql/query.yaml index 6765ab430..5b47ec2a3 100644 --- a/tests/sql/query.yaml +++ b/tests/sql/query.yaml @@ -2,29 +2,22 @@ $schema: ../../json_schemas/test_story.schema.yaml description: Test send SQL query to index. -epilogues: - - path: /_plugins/_sql - method: POST - request_body: - payload: - query: SELECT name FROM books1 - status: [200] -chapters: - - synopsis: Create an index named `books` with mappings and settings. - path: /{index} +prologues: + - path: /{index} method: PUT parameters: - index: books1 + index: books + request_body: + payload: {} +epilogues: + - path: /books + method: DELETE + status: [200, 404] +chapters: + - synopsis: Get SQL query + path: /_plugins/_sql/ + method: POST request_body: payload: - mappings: - properties: - name: - type: keyword - age: - type: integer - settings: - number_of_shards: 5 - number_of_replicas: 2 - response: - status: 200 \ No newline at end of file + query: SELECT * FROM books + status: [200] \ No newline at end of file diff --git a/tests/sql/stats.yaml b/tests/sql/stats.yaml new file mode 100644 index 000000000..7a3c59714 --- /dev/null +++ b/tests/sql/stats.yaml @@ -0,0 +1,24 @@ +$schema: ../../json_schemas/test_story.schema.yaml + +description: Test get SQL Queries stats. + +prologues: + - path: /{index} + method: PUT + parameters: + index: books + request_body: + payload: {} +epilogues: + - path: /books + method: DELETE + status: [200, 404] + +chapters: + - synopsis: Get stats from SQL Query + path: /_plugins/_sql/stats + method: POST + request_body: + payload: + query: SELECT * FROM books + status: [200] \ No newline at end of file From 7ae06fb942f9ab383c9713cee1ee1dc009725449 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 21 Jul 2024 23:32:39 +0500 Subject: [PATCH 15/26] fixing tests for sql namespace Signed-off-by: Tokesh --- .env | 0 tests/sql/close.yaml | 28 ++++++++++++++++++++-------- tests/sql/explain.yaml | 9 ++++----- tests/sql/query.yaml | 7 ++++--- tests/sql/stats.yaml | 20 +++----------------- tools/src/OpenSearchHttpClient.ts | 2 +- 6 files changed, 32 insertions(+), 34 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 000000000..e69de29bb diff --git a/tests/sql/close.yaml b/tests/sql/close.yaml index 4f6fd87cf..2e2eb773d 100644 --- a/tests/sql/close.yaml +++ b/tests/sql/close.yaml @@ -6,30 +6,42 @@ prologues: - path: /{index} method: PUT parameters: - index: books + index: books1 request_body: payload: {} epilogues: - - path: /books + - path: /books1 method: DELETE status: [200, 404] chapters: - - synopsis: Get SQL query + - synopsis: Create a document. + path: /{index}/_doc + method: POST + parameters: + index: books + request_body: + payload: + title: Beauty and the Beast + year: 1991 + response: + status: 201 + - synopsis: Get SQL query. id: query_sql path: /_plugins/_sql method: POST request_body: payload: - query: SELECT * FROM books fetch_size: 1 + query: SELECT * FROM books + response: + status: 200 output: cursor: "payload.cursor" - status: [200] - synopsis: Close cursor path: /_plugins/_sql/close method: POST request_body: payload: - cursor: - - ${query_sql.cursor} - status: [200] \ No newline at end of file + cursor: ${query_sql.cursor} + response: + status: 200 \ No newline at end of file diff --git a/tests/sql/explain.yaml b/tests/sql/explain.yaml index 9a13bbad2..16ea254f8 100644 --- a/tests/sql/explain.yaml +++ b/tests/sql/explain.yaml @@ -3,10 +3,8 @@ $schema: ../../json_schemas/test_story.schema.yaml description: Test how a query is executed against OpenSearch. prologues: - - path: /{index} + - path: /books method: PUT - parameters: - index: books request_body: payload: {} epilogues: @@ -15,9 +13,10 @@ epilogues: status: [200, 404] chapters: - synopsis: Get explain of SQL Query - path: /_plugins/_sql/explain + path: /_plugins/_sql/_explain method: POST request_body: payload: query: SELECT * FROM books - status: [200] + response: + status: 200 diff --git a/tests/sql/query.yaml b/tests/sql/query.yaml index 5b47ec2a3..b9b63fc8e 100644 --- a/tests/sql/query.yaml +++ b/tests/sql/query.yaml @@ -15,9 +15,10 @@ epilogues: status: [200, 404] chapters: - synopsis: Get SQL query - path: /_plugins/_sql/ + path: /_plugins/_sql method: POST request_body: payload: - query: SELECT * FROM books - status: [200] \ No newline at end of file + query: "SELECT * FROM books" + response: + status: 200 \ No newline at end of file diff --git a/tests/sql/stats.yaml b/tests/sql/stats.yaml index 7a3c59714..d56838b9c 100644 --- a/tests/sql/stats.yaml +++ b/tests/sql/stats.yaml @@ -2,23 +2,9 @@ $schema: ../../json_schemas/test_story.schema.yaml description: Test get SQL Queries stats. -prologues: - - path: /{index} - method: PUT - parameters: - index: books - request_body: - payload: {} -epilogues: - - path: /books - method: DELETE - status: [200, 404] - chapters: - - synopsis: Get stats from SQL Query + - synopsis: Get stats from SQL Query. path: /_plugins/_sql/stats method: POST - request_body: - payload: - query: SELECT * FROM books - status: [200] \ No newline at end of file + response: + status: 200 \ No newline at end of file diff --git a/tools/src/OpenSearchHttpClient.ts b/tools/src/OpenSearchHttpClient.ts index 7ffcb1421..5f780a922 100644 --- a/tools/src/OpenSearchHttpClient.ts +++ b/tools/src/OpenSearchHttpClient.ts @@ -12,7 +12,7 @@ import axios, { type AxiosInstance, type AxiosRequestConfig, type AxiosResponse, import * as https from 'node:https' import { sleep } from './helpers' -const DEFAULT_URL = 'https://localhost:9200' +const DEFAULT_URL = 'http://localhost:9200' const DEFAULT_USER = 'admin' const DEFAULT_INSECURE = false From 7efd2bba6b13751558e0fa16b30ef0fbe958f46b Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 21 Jul 2024 23:42:27 +0500 Subject: [PATCH 16/26] fixing lint Signed-off-by: Tokesh --- .env | 0 spec/schemas/sql._common.yaml | 2 +- tests/_core/bulk.yaml | 26 +++++++++++++------------- tests/sql/close.yaml | 2 +- tools/src/OpenSearchHttpClient.ts | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index e69de29bb..000000000 diff --git a/spec/schemas/sql._common.yaml b/spec/schemas/sql._common.yaml index 878bc3928..5980dc07f 100644 --- a/spec/schemas/sql._common.yaml +++ b/spec/schemas/sql._common.yaml @@ -24,7 +24,7 @@ components: type: object data_rows: type: array - items: # this is 2d array. Is it normal to write like this? Or perhaps we need to define DataRows structure at the bottom? + items: type: array items: type: object diff --git a/tests/_core/bulk.yaml b/tests/_core/bulk.yaml index e7cc18cb0..f5cb71dae 100644 --- a/tests/_core/bulk.yaml +++ b/tests/_core/bulk.yaml @@ -12,23 +12,23 @@ chapters: request_body: content_type: application/x-ndjson payload: - - { create: { _index: movies } } - - { director: Bennett Miller, title: Moneyball, year: 2011 } + - {create: {_index: movies}} + - {director: Bennett Miller, title: Moneyball, year: 2011} - synopsis: Bulk document CRUD. path: /_bulk method: POST request_body: content_type: application/x-ndjson payload: - - { create: { _index: books, _id: book_1392214 } } - - { author: Harper Lee, title: To Kill a Mockingbird, year: 1960 } - - { update: { _index: books, _id: book_1392214 } } - - { doc: { pages: 376 } } - - { update: { _index: books, _id: book_1392214 } } - - { doc: { pages: 376 }, _source: true } - - { update: { _index: books, _id: book_1392214 } } - - { script: { source: 'ctx._source.pages = 376;' } } - - { update: { _index: books, _id: does_not_exist } } - - { script: { source: 'ctx.op = "none";' }, scripted_upsert: true, upsert: { pages: 375 } } - - { delete: { _index: books, _id: book_1392214 } } + - {create: {_index: books, _id: book_1392214}} + - {author: Harper Lee, title: To Kill a Mockingbird, year: 1960} + - {update: {_index: books, _id: book_1392214}} + - {doc: {pages: 376}} + - {update: {_index: books, _id: book_1392214}} + - {doc: {pages: 376}, _source: true} + - {update: {_index: books, _id: book_1392214}} + - {script: {source: 'ctx._source.pages = 376;'}} + - {update: {_index: books, _id: does_not_exist}} + - {script: {source: 'ctx.op = "none";'}, scripted_upsert: true, upsert: {pages: 375}} + - {delete: {_index: books, _id: book_1392214}} diff --git a/tests/sql/close.yaml b/tests/sql/close.yaml index 2e2eb773d..eae3e3e59 100644 --- a/tests/sql/close.yaml +++ b/tests/sql/close.yaml @@ -36,7 +36,7 @@ chapters: response: status: 200 output: - cursor: "payload.cursor" + cursor: 'payload.cursor' - synopsis: Close cursor path: /_plugins/_sql/close method: POST diff --git a/tools/src/OpenSearchHttpClient.ts b/tools/src/OpenSearchHttpClient.ts index 5f780a922..7ffcb1421 100644 --- a/tools/src/OpenSearchHttpClient.ts +++ b/tools/src/OpenSearchHttpClient.ts @@ -12,7 +12,7 @@ import axios, { type AxiosInstance, type AxiosRequestConfig, type AxiosResponse, import * as https from 'node:https' import { sleep } from './helpers' -const DEFAULT_URL = 'http://localhost:9200' +const DEFAULT_URL = 'https://localhost:9200' const DEFAULT_USER = 'admin' const DEFAULT_INSECURE = false From a9b20c503cbe9d33c729176cc35243c5e5d6db11 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Wed, 24 Jul 2024 09:02:21 +0500 Subject: [PATCH 17/26] fixing status in request body of sql query API Signed-off-by: Tokesh --- spec/schemas/sql._common.yaml | 2 +- tests/sql/close.yaml | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/spec/schemas/sql._common.yaml b/spec/schemas/sql._common.yaml index 5980dc07f..6758bf596 100644 --- a/spec/schemas/sql._common.yaml +++ b/spec/schemas/sql._common.yaml @@ -33,7 +33,7 @@ components: size: type: integer status: - type: string + type: integer SqlExplain: type: object properties: diff --git a/tests/sql/close.yaml b/tests/sql/close.yaml index eae3e3e59..ff5f4f14b 100644 --- a/tests/sql/close.yaml +++ b/tests/sql/close.yaml @@ -6,11 +6,11 @@ prologues: - path: /{index} method: PUT parameters: - index: books1 + index: books request_body: payload: {} epilogues: - - path: /books1 + - path: /books method: DELETE status: [200, 404] chapters: @@ -25,6 +25,13 @@ chapters: year: 1991 response: status: 201 + - synopsis: Refresh the index. + path: /{index}/_refresh + method: POST + parameters: + index: books + response: + status: 200 - synopsis: Get SQL query. id: query_sql path: /_plugins/_sql @@ -32,7 +39,7 @@ chapters: request_body: payload: fetch_size: 1 - query: SELECT * FROM books + query: "SELECT * FROM books" response: status: 200 output: From ebddcefe79d0c45e09d4adfd6fb439c8dad25d96 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Wed, 24 Jul 2024 09:33:26 +0500 Subject: [PATCH 18/26] hotfix of sql query structure Signed-off-by: Tokesh --- spec/schemas/sql._common.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spec/schemas/sql._common.yaml b/spec/schemas/sql._common.yaml index 6758bf596..75746eac2 100644 --- a/spec/schemas/sql._common.yaml +++ b/spec/schemas/sql._common.yaml @@ -6,7 +6,7 @@ info: paths: {} components: schemas: - SqlQuery: # Can we name it just Query? + SqlQuery: type: object properties: query: @@ -22,12 +22,10 @@ components: type: array items: type: object - data_rows: + datarows: type: array items: type: array - items: - type: object total: type: integer size: From a14a618f1d9e27525114d1cbebe5aa25bedcc593 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Wed, 24 Jul 2024 10:43:51 +0500 Subject: [PATCH 19/26] fix structure of sql stats API Signed-off-by: Tokesh --- spec/namespaces/sql.yaml | 8 ++++---- spec/schemas/sql._common.yaml | 2 ++ tests/sql/stats.yaml | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index c9e8fe36d..fc3cf4a64 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -204,13 +204,13 @@ components: required: true sql.get_stats@200: content: - application/json: + text/plain: schema: - $ref: '../schemas/sql._common.yaml#/components/schemas/SqlStatsResponse' + type: string required: true sql.post_stats@200: content: - application/json: + text/plain: schema: - $ref: '../schemas/sql._common.yaml#/components/schemas/SqlStatsResponse' + type: string required: true \ No newline at end of file diff --git a/spec/schemas/sql._common.yaml b/spec/schemas/sql._common.yaml index 75746eac2..785a06468 100644 --- a/spec/schemas/sql._common.yaml +++ b/spec/schemas/sql._common.yaml @@ -26,6 +26,8 @@ components: type: array items: type: array + cursor: + type: string total: type: integer size: diff --git a/tests/sql/stats.yaml b/tests/sql/stats.yaml index d56838b9c..cbb8d7db1 100644 --- a/tests/sql/stats.yaml +++ b/tests/sql/stats.yaml @@ -7,4 +7,5 @@ chapters: path: /_plugins/_sql/stats method: POST response: - status: 200 \ No newline at end of file + status: 200 + content_type: text/plain \ No newline at end of file From f3003df24c4fafb60f64820b6747d2faeda90b61 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Wed, 24 Jul 2024 21:11:58 +0500 Subject: [PATCH 20/26] fix linter, descriptions Signed-off-by: Tokesh --- .cspell | 3 +++ spec/namespaces/sql.yaml | 6 +++--- tests/_core/bulk.yaml | 2 +- tests/sql/close.yaml | 4 ++-- tests/sql/query.yaml | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.cspell b/.cspell index 37a004c69..d4c94dcc4 100644 --- a/.cspell +++ b/.cspell @@ -177,3 +177,6 @@ urldecode vectory whoamiprotected wordnet +datarows +syserr +cuserr \ No newline at end of file diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index fc3cf4a64..6bfe9e72e 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -9,7 +9,7 @@ paths: operationId: sql.query.0 x-operation-group: sql.query x-version-added: '1.0' - description: Sends an SQL/PPL query to the SQL plugin. + description: Send a SQL/PPL query to the SQL plugin. externalDocs: url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ parameters: @@ -41,7 +41,7 @@ paths: operationId: sql.close.0 x-operation-group: sql.close x-version-added: '1.0' - description: To explicitly clear the cursor context. + description: Clears the cursor context. externalDocs: url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ parameters: @@ -57,7 +57,7 @@ paths: operationId: sql.get_stats.0 x-operation-group: sql.get_stats x-version-added: '1.0' - description: By a stats endpoint, you are able to collect metrics for the plugin within the interval. + description: Collect metrics for the plugin within the interval. externalDocs: url: https://opensearch.org/docs/latest/search-plugins/sql/monitoring/ parameters: diff --git a/tests/_core/bulk.yaml b/tests/_core/bulk.yaml index f5cb71dae..c480b926e 100644 --- a/tests/_core/bulk.yaml +++ b/tests/_core/bulk.yaml @@ -27,7 +27,7 @@ chapters: - {update: {_index: books, _id: book_1392214}} - {doc: {pages: 376}, _source: true} - {update: {_index: books, _id: book_1392214}} - - {script: {source: 'ctx._source.pages = 376;'}} + - {script: {source: ctx._source.pages = 376;}} - {update: {_index: books, _id: does_not_exist}} - {script: {source: 'ctx.op = "none";'}, scripted_upsert: true, upsert: {pages: 375}} - {delete: {_index: books, _id: book_1392214}} diff --git a/tests/sql/close.yaml b/tests/sql/close.yaml index ff5f4f14b..1047325ec 100644 --- a/tests/sql/close.yaml +++ b/tests/sql/close.yaml @@ -39,11 +39,11 @@ chapters: request_body: payload: fetch_size: 1 - query: "SELECT * FROM books" + query: 'SELECT * FROM books' response: status: 200 output: - cursor: 'payload.cursor' + cursor: payload.cursor - synopsis: Close cursor path: /_plugins/_sql/close method: POST diff --git a/tests/sql/query.yaml b/tests/sql/query.yaml index b9b63fc8e..9dba20594 100644 --- a/tests/sql/query.yaml +++ b/tests/sql/query.yaml @@ -19,6 +19,6 @@ chapters: method: POST request_body: payload: - query: "SELECT * FROM books" + query: 'SELECT * FROM books' response: status: 200 \ No newline at end of file From bf278c8828ff8fe2392db5155908ab4c5ebd369a Mon Sep 17 00:00:00 2001 From: Tokesh Date: Wed, 24 Jul 2024 21:18:03 +0500 Subject: [PATCH 21/26] fixing specs-validate ci Signed-off-by: Tokesh --- spec/schemas/sql._common.yaml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/spec/schemas/sql._common.yaml b/spec/schemas/sql._common.yaml index 785a06468..c704fb044 100644 --- a/spec/schemas/sql._common.yaml +++ b/spec/schemas/sql._common.yaml @@ -86,16 +86,16 @@ components: type: object execution_time: type: object - SqlStatsResponse: - type: object - properties: - request_total: - type: integer - request_count: - type: integer - failed_request_count_syserr: - type: integer - failed_request_count_cuserr: - type: integer - failed_request_count_cb: - type: integer \ No newline at end of file + # SqlStatsResponse: + # type: object + # properties: + # request_total: + # type: integer + # request_count: + # type: integer + # failed_request_count_syserr: + # type: integer + # failed_request_count_cuserr: + # type: integer + # failed_request_count_cb: + # type: integer \ No newline at end of file From ede9abaec081e3a15befe4eb8093647331ba672e Mon Sep 17 00:00:00 2001 From: Tokesh Date: Wed, 24 Jul 2024 21:22:46 +0500 Subject: [PATCH 22/26] adding verbose to check error in tests Signed-off-by: Tokesh --- .github/workflows/test-spec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-spec.yml b/.github/workflows/test-spec.yml index 809c1a63f..682eac75f 100644 --- a/.github/workflows/test-spec.yml +++ b/.github/workflows/test-spec.yml @@ -55,7 +55,7 @@ jobs: - name: Run Tests run: | - npm run test:spec -- --opensearch-insecure --coverage coverage/test-spec-coverage-${{ matrix.entry.version }}.json + npm run test:spec -- --opensearch-insecure --verbose --coverage coverage/test-spec-coverage-${{ matrix.entry.version }}.json - name: Upload Test Coverage Results uses: actions/upload-artifact@v4 From 0c29ed7547fe1d0371b4154aae62540822a5b6f2 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Wed, 24 Jul 2024 21:38:12 +0500 Subject: [PATCH 23/26] adding second document to receive cursor Signed-off-by: Tokesh --- tests/sql/close.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/sql/close.yaml b/tests/sql/close.yaml index 1047325ec..249ccbefe 100644 --- a/tests/sql/close.yaml +++ b/tests/sql/close.yaml @@ -25,6 +25,17 @@ chapters: year: 1991 response: status: 201 + - synopsis: Create a document. + path: /{index}/_doc + method: POST + parameters: + index: books + request_body: + payload: + title: To name the bigger life + year: 2004 + response: + status: 201 - synopsis: Refresh the index. path: /{index}/_refresh method: POST From 8514dfdcaa8326ea949133b905678d806e9d3052 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Wed, 24 Jul 2024 22:14:25 +0500 Subject: [PATCH 24/26] added bulk in close API tests, description of PR to changelog, deleting comment and temporary ci setting Signed-off-by: Tokesh --- .github/workflows/test-spec.yml | 2 +- CHANGELOG.md | 1 + spec/namespaces/sql.yaml | 2 +- spec/schemas/sql._common.yaml | 15 +-------------- tests/sql/close.yaml | 26 +++++++------------------- 5 files changed, 11 insertions(+), 35 deletions(-) diff --git a/.github/workflows/test-spec.yml b/.github/workflows/test-spec.yml index 682eac75f..809c1a63f 100644 --- a/.github/workflows/test-spec.yml +++ b/.github/workflows/test-spec.yml @@ -55,7 +55,7 @@ jobs: - name: Run Tests run: | - npm run test:spec -- --opensearch-insecure --verbose --coverage coverage/test-spec-coverage-${{ matrix.entry.version }}.json + npm run test:spec -- --opensearch-insecure --coverage coverage/test-spec-coverage-${{ matrix.entry.version }}.json - name: Upload Test Coverage Results uses: actions/upload-artifact@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index aa24870ba..f124dab1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added AjvErrorsParser to print more informative error messages ([#364](https://github.com/opensearch-project/opensearch-api-specification/issues/364)) - Added JsonSchemaValidator, a wrapper for AJV ([#364](https://github.com/opensearch-project/opensearch-api-specification/issues/364)) - Added support for `application/cbor` responses ([#371](https://github.com/opensearch-project/opensearch-api-specification/pull/371)) +- Added tests for SQL namespace ([#379](https://github.com/opensearch-project/opensearch-api-specification/pull/379)) - Added support for `application/smile` responses ([#386](https://github.com/opensearch-project/opensearch-api-specification/pull/386)) - Added `doc_status`, `remote_store`, `segment_replication` and `unreferenced_file_cleanups_performed` to `SegmentStats` ([#395](https://github.com/opensearch-project/opensearch-api-specification/pull/395)) - Added `concurrent_query_*` and `search_idle_reactivate_count_total` fields to `SearchStats` ([#395](https://github.com/opensearch-project/opensearch-api-specification/pull/395)) diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index 6bfe9e72e..0afdde2d8 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -41,7 +41,7 @@ paths: operationId: sql.close.0 x-operation-group: sql.close x-version-added: '1.0' - description: Clears the cursor context. + description: Clear the cursor context. externalDocs: url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ parameters: diff --git a/spec/schemas/sql._common.yaml b/spec/schemas/sql._common.yaml index c704fb044..ea1abf9f0 100644 --- a/spec/schemas/sql._common.yaml +++ b/spec/schemas/sql._common.yaml @@ -85,17 +85,4 @@ components: user: type: object execution_time: - type: object - # SqlStatsResponse: - # type: object - # properties: - # request_total: - # type: integer - # request_count: - # type: integer - # failed_request_count_syserr: - # type: integer - # failed_request_count_cuserr: - # type: integer - # failed_request_count_cb: - # type: integer \ No newline at end of file + type: object \ No newline at end of file diff --git a/tests/sql/close.yaml b/tests/sql/close.yaml index 249ccbefe..db1cbb84c 100644 --- a/tests/sql/close.yaml +++ b/tests/sql/close.yaml @@ -14,28 +14,16 @@ epilogues: method: DELETE status: [200, 404] chapters: - - synopsis: Create a document. - path: /{index}/_doc + - synopsis: Create few documents. + path: /_bulk method: POST - parameters: - index: books request_body: + content_type: application/x-ndjson payload: - title: Beauty and the Beast - year: 1991 - response: - status: 201 - - synopsis: Create a document. - path: /{index}/_doc - method: POST - parameters: - index: books - request_body: - payload: - title: To name the bigger life - year: 2004 - response: - status: 201 + - {create: {_index: books, _id: book_1392214}} + - {author: Harper Lee, title: To Kill a Mockingbird, year: 1960} + - {create: {_index: books, _id: book_1392215}} + - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991} - synopsis: Refresh the index. path: /{index}/_refresh method: POST From 8cd485b16767fddb52f1a51c5e2056ae4f62f75e Mon Sep 17 00:00:00 2001 From: Tokesh Date: Wed, 24 Jul 2024 22:16:42 +0500 Subject: [PATCH 25/26] adding author name to cspell Signed-off-by: Tokesh --- .cspell | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.cspell b/.cspell index d4c94dcc4..08aa8908c 100644 --- a/.cspell +++ b/.cspell @@ -179,4 +179,5 @@ whoamiprotected wordnet datarows syserr -cuserr \ No newline at end of file +cuserr +Rudnick \ No newline at end of file From 1573d8b26b19b9bbbe93a6dab19852b824969294 Mon Sep 17 00:00:00 2001 From: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> Date: Thu, 25 Jul 2024 21:09:27 +0500 Subject: [PATCH 26/26] adding text to changelog and refactoring code from chapters to prologue Signed-off-by: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> --- CHANGELOG.md | 1 + tests/sql/close.yaml | 20 ++++++++------------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f124dab1c..d6563e391 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added AjvErrorsParser to print more informative error messages ([#364](https://github.com/opensearch-project/opensearch-api-specification/issues/364)) - Added JsonSchemaValidator, a wrapper for AJV ([#364](https://github.com/opensearch-project/opensearch-api-specification/issues/364)) - Added support for `application/cbor` responses ([#371](https://github.com/opensearch-project/opensearch-api-specification/pull/371)) +- Added `/_plugins/_sql`, `close`, `explain` and `stats` ([#379](https://github.com/opensearch-project/opensearch-api-specification/pull/379)) - Added tests for SQL namespace ([#379](https://github.com/opensearch-project/opensearch-api-specification/pull/379)) - Added support for `application/smile` responses ([#386](https://github.com/opensearch-project/opensearch-api-specification/pull/386)) - Added `doc_status`, `remote_store`, `segment_replication` and `unreferenced_file_cleanups_performed` to `SegmentStats` ([#395](https://github.com/opensearch-project/opensearch-api-specification/pull/395)) diff --git a/tests/sql/close.yaml b/tests/sql/close.yaml index db1cbb84c..3c23a6299 100644 --- a/tests/sql/close.yaml +++ b/tests/sql/close.yaml @@ -9,13 +9,7 @@ prologues: index: books request_body: payload: {} -epilogues: - - path: /books - method: DELETE - status: [200, 404] -chapters: - - synopsis: Create few documents. - path: /_bulk + - path: /_bulk method: POST request_body: content_type: application/x-ndjson @@ -24,13 +18,15 @@ chapters: - {author: Harper Lee, title: To Kill a Mockingbird, year: 1960} - {create: {_index: books, _id: book_1392215}} - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991} - - synopsis: Refresh the index. - path: /{index}/_refresh + - path: /{index}/_refresh method: POST parameters: index: books - response: - status: 200 +epilogues: + - path: /books + method: DELETE + status: [200, 404] +chapters: - synopsis: Get SQL query. id: query_sql path: /_plugins/_sql @@ -43,7 +39,7 @@ chapters: status: 200 output: cursor: payload.cursor - - synopsis: Close cursor + - synopsis: Close cursor. path: /_plugins/_sql/close method: POST request_body: