Skip to content

Commit

Permalink
Adding SQL Settings specs (#456)
Browse files Browse the repository at this point in the history
* adding specs and tests for SQL Settings API

Signed-off-by: Tokesh <[email protected]>

* fix lint and validate ci

Signed-off-by: Tokesh <[email protected]>

* adding version plain version of request body

Signed-off-by: Tokesh <[email protected]>

* hotfix lint

Signed-off-by: Tokesh <[email protected]>

* deleting unnecessary descriptions in sql namespace specs

Signed-off-by: Tokesh <[email protected]>

* adding anyOf to few parameters in SQL schemas

Signed-off-by: Tokesh <[email protected]>

* adding changelog changes

Signed-off-by: Niyazbek Torekeldi <[email protected]>

* fixing types in tests

Signed-off-by: Tokesh <[email protected]>

---------

Signed-off-by: Tokesh <[email protected]>
Signed-off-by: Niyazbek Torekeldi <[email protected]>
  • Loading branch information
Tokesh authored Aug 2, 2024
1 parent b67104c commit 2ca485a
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 15 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- 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))
- Added `concurrent_query_*` and `search_idle_reactivate_count_total` fields to `SearchStats` ([#395](https://github.com/opensearch-project/opensearch-api-specification/pull/395))
Expand All @@ -58,7 +57,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added `retry` to `tester` to support asynchronous tasks ([453](https://github.com/opensearch-project/opensearch-api-specification/pull/453))
- Added passing OPENSEARCH_JAVA_OPTS into the docker container used for tests ([#454](https://github.com/opensearch-project/opensearch-api-specification/pull/454))
- Added a warning on mulitple paths being tested in the same file ([#452](https://github.com/opensearch-project/opensearch-api-specification/pull/452))

- Added `/_plugins/_query/settings` ([#456](https://github.com/opensearch-project/opensearch-api-specification/pull/456))

### Changed

- Replaced Smithy with a native OpenAPI spec ([#189](https://github.com/opensearch-project/opensearch-api-specification/issues/189))
Expand Down
2 changes: 1 addition & 1 deletion spec/_superseded_operations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml
operations:
- POST
/_opendistro/_sql/settings:
superseded_by: /_plugins/_sql/settings
superseded_by: /_plugins/_query/settings
operations:
- PUT
/_opendistro/_sql/stats:
Expand Down
45 changes: 34 additions & 11 deletions spec/namespaces/sql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ info:
description: OpenSearch SQL API
version: 1.0.0
paths:
/_plugins/_query/settings:
put:
operationId: sql.settings.0
x-operation-group: sql.settings
x-version-added: '1.0'
description: Adds SQL settings to the standard OpenSearch cluster settings.
externalDocs:
url: https://opensearch.org/docs/latest/search-plugins/sql/settings/
parameters:
- $ref: '#/components/parameters/sql.settings::query.format'
requestBody:
$ref: '#/components/requestBodies/sql.settings'
responses:
'200':
$ref: '#/components/responses/sql.settings@200'
/_plugins/_sql:
post:
operationId: sql.query.0
Expand Down Expand Up @@ -83,82 +98,86 @@ paths:
$ref: '#/components/responses/sql.post_stats@200'
components:
parameters:
sql.settings::query.format:
name: format
in: query
description: A short version of the Accept header, e.g. json, yaml.
schema:
type: string
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::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.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.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.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
schema:
type: boolean
default: true
description: Specifies whether to escape special characters in the results
requestBodies:
sql.settings:
content:
application/json:
schema:
anyOf:
- $ref: '../schemas/sql._common.yaml#/components/schemas/SqlSettingsPlain'
- $ref: '../schemas/sql._common.yaml#/components/schemas/SqlSettings'
required: true
sql.query:
content:
application/json:
Expand All @@ -184,8 +203,12 @@ components:
$ref: '../schemas/sql._common.yaml#/components/schemas/SqlStats'
required: true
responses:
sql.settings@200:
content:
application/json:
schema:
$ref: '../schemas/sql._common.yaml#/components/schemas/SqlSettingsResponse'
sql.query@200:
description: ''
content:
application/json:
schema:
Expand Down
84 changes: 83 additions & 1 deletion spec/schemas/sql._common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,86 @@ components:
user:
type: object
execution_time:
type: object
type: object
SqlSettings:
type: object
properties:
transient:
$ref: '#/components/schemas/Transient'
SqlSettingsPlain:
type: object
properties:
transient:
$ref: '#/components/schemas/TransientPlain'
SqlSettingsResponse:
type: object
properties:
acknowledged:
type: boolean
persistent:
type: object
transient:
$ref: '#/components/schemas/Transient'
Transient:
type: object
properties:
plugins:
$ref: '#/components/schemas/Plugins'
Plugins:
type: object
properties:
ppl:
$ref: '#/components/schemas/Ppl'
query:
$ref: '#/components/schemas/Query'
sql:
$ref: '#/components/schemas/Sql'
Ppl:
type: object
properties:
enabled:
anyOf:
- type: boolean
- type: string
Query:
type: object
properties:
memory_limit:
type: string
size_limit:
anyOf:
- type: string
- type: integer
Sql:
type: object
properties:
enabled:
anyOf:
- type: boolean
- type: string
slowlog:
anyOf:
- type: integer
- type: string
cursor:
$ref: '#/components/schemas/Cursor'
Cursor:
type: object
properties:
keep_alive:
type: string
TransientPlain:
type: object
properties:
plugins.sql.enabled:
type: boolean
plugins.ppl.enabled:
type: boolean
plugins.sql.slowlog:
type: integer
plugins.sql.cursor.keep_alive:
type: string
plugins.query.memory_limit:
type: string
plugins.query.size_limit:
type: integer
2 changes: 2 additions & 0 deletions tests/sql/query.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ chapters:
- synopsis: Get SQL query
path: /_plugins/_sql
method: POST
parameters:
sanitize: false
request_body:
payload:
query: 'SELECT * FROM books'
Expand Down
38 changes: 38 additions & 0 deletions tests/sql/settings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test updating SQL settings in OS cluster.

chapters:
- synopsis: Update SQL settings.
path: /_plugins/_query/settings
method: PUT
request_body:
payload:
transient:
plugins:
sql:
enabled: true
slowlog: '2'
cursor:
keep_alive: 1m
ppl:
enabled: true
query:
memory_limit: '80%'
size_limit: 200
response:
status: 200
- synopsis: Update SQL settings with plain request body.
path: /_plugins/_query/settings
method: PUT
request_body:
payload:
transient:
plugins.sql.enabled: true
plugins.ppl.enabled: true
plugins.sql.slowlog: 2
plugins.sql.cursor.keep_alive: 1m
plugins.query.memory_limit: '80%'
plugins.query.size_limit: 200
response:
status: 200

0 comments on commit 2ca485a

Please sign in to comment.