Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding SQL Settings specs #456

Merged
merged 9 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion 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))
dblock marked this conversation as resolved.
Show resolved Hide resolved
- 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 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
dblock marked this conversation as resolved.
Show resolved Hide resolved
operations:
- PUT
/_opendistro/_sql/stats:
Expand Down
36 changes: 36 additions & 0 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:
dblock marked this conversation as resolved.
Show resolved Hide resolved
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,6 +98,13 @@ 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
description: A short version of the Accept header, e.g. json, yaml.
Tokesh marked this conversation as resolved.
Show resolved Hide resolved
sql.query::query.format:
name: format
in: query
Expand Down Expand Up @@ -159,6 +181,14 @@ components:
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,6 +214,12 @@ components:
$ref: '../schemas/sql._common.yaml#/components/schemas/SqlStats'
required: true
responses:
sql.settings@200:
description: ''
Tokesh marked this conversation as resolved.
Show resolved Hide resolved
content:
application/json:
schema:
$ref: '../schemas/sql._common.yaml#/components/schemas/SqlSettingsResponse'
sql.query@200:
description: ''
content:
Expand Down
76 changes: 75 additions & 1 deletion spec/schemas/sql._common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,78 @@ 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:
type: string
Query:
type: object
properties:
memory_limit:
type: string
size_limit:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double-checking that those are actually strings?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API accept string and also numbers.
image
image

type: string
Sql:
type: object
properties:
enabled:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean?

type: string
slowlog:
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
dblock marked this conversation as resolved.
Show resolved Hide resolved
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'
Tokesh marked this conversation as resolved.
Show resolved Hide resolved
slowlog: '2'
cursor:
keep_alive: 1m
ppl:
enabled: 'true'
query:
memory_limit: '80%'
size_limit: '200'
Tokesh marked this conversation as resolved.
Show resolved Hide resolved
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
Loading