mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-01 16:39:11 +00:00
SQL: Basic REST spec and tests (elastic/x-pack-elasticsearch#3128)
Adds a basic REST spec and tests for the SQL and translate endpoints so that clients can can execute these endpoints. We'll keep our complex REST testing in Java REST tests though. relates elastic/x-pack-elasticsearch#3115 Original commit: elastic/x-pack-elasticsearch@c5de301f3d
This commit is contained in:
parent
626e9b87a1
commit
378abf1d8f
16
plugin/src/test/resources/rest-api-spec/api/xpack.sql.json
Normal file
16
plugin/src/test/resources/rest-api-spec/api/xpack.sql.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"xpack.sql": {
|
||||||
|
"documentation": "Execute SQL",
|
||||||
|
"methods": [ "POST", "GET" ],
|
||||||
|
"url": {
|
||||||
|
"path": "/_sql",
|
||||||
|
"paths": [ "/_sql" ],
|
||||||
|
"parts": {},
|
||||||
|
"params": {}
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"description" : "Use the `query` element to start a query. Use the `cursor` element to continue a query.",
|
||||||
|
"required" : true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"xpack.sql.translate": {
|
||||||
|
"documentation": "Translate SQL into Elasticsearch queries",
|
||||||
|
"methods": [ "POST", "GET" ],
|
||||||
|
"url": {
|
||||||
|
"path": "/_sql/translate",
|
||||||
|
"paths": [ "/_sql/translate" ],
|
||||||
|
"parts": {},
|
||||||
|
"params": {}
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"description" : "Specify the query in the `query` element.",
|
||||||
|
"required" : true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
29
plugin/src/test/resources/rest-api-spec/test/sql/sql.yml
Normal file
29
plugin/src/test/resources/rest-api-spec/test/sql/sql.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
"Execute some SQL":
|
||||||
|
- do:
|
||||||
|
bulk:
|
||||||
|
refresh: true
|
||||||
|
body:
|
||||||
|
- index:
|
||||||
|
_index: test
|
||||||
|
_type: doc
|
||||||
|
_id: 1
|
||||||
|
- str: test1
|
||||||
|
int: 1
|
||||||
|
- index:
|
||||||
|
_index: test
|
||||||
|
_type: doc
|
||||||
|
_id: 2
|
||||||
|
- str: test2
|
||||||
|
int: 2
|
||||||
|
|
||||||
|
- do:
|
||||||
|
xpack.sql:
|
||||||
|
body:
|
||||||
|
query: "SELECT * FROM test ORDER BY int asc"
|
||||||
|
- match: { columns.0.name: int }
|
||||||
|
- match: { columns.1.name: str }
|
||||||
|
- match: { rows.0.0: 1 }
|
||||||
|
- match: { rows.0.1: test1 }
|
||||||
|
- match: { rows.1.0: 2 }
|
||||||
|
- match: { rows.1.1: test2 }
|
@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
"Translate SQL":
|
||||||
|
- do:
|
||||||
|
bulk:
|
||||||
|
refresh: true
|
||||||
|
body:
|
||||||
|
- index:
|
||||||
|
_index: test
|
||||||
|
_type: doc
|
||||||
|
_id: 1
|
||||||
|
- str: test1
|
||||||
|
int: 1
|
||||||
|
|
||||||
|
- do:
|
||||||
|
xpack.sql.translate:
|
||||||
|
body:
|
||||||
|
query: "SELECT * FROM test ORDER BY int asc"
|
||||||
|
- match:
|
||||||
|
$body:
|
||||||
|
size: 1000
|
||||||
|
_source:
|
||||||
|
includes:
|
||||||
|
- str
|
||||||
|
excludes: []
|
||||||
|
docvalue_fields:
|
||||||
|
- int
|
||||||
|
sort:
|
||||||
|
- int:
|
||||||
|
order: asc
|
Loading…
x
Reference in New Issue
Block a user