create-query
Written by
Updated at May 13, 2024
The method creates a data query and runs it. After that, the query status changes to RUNNING
. You can only get results once the query completes successfully. To find out the query status, use the get-query-status method.
When using the HTTP API, authenticate and specify the required headers. You can also specify optional headers for setting up request execution. The HTTP API may return errors while running.
Query
POST
query to /queries?project={folder_id}
, where {folder_id}
is the folder ID.
The query body contains data in JSON format:
{
"name": "human readable default name",
"type": "ANALYTICS",
"text": "string",
"description": ""
}
Field | Description | Acceptable values | Comment | Limitations |
---|---|---|---|---|
name |
Query name | If the parameter is not specified, it is assigned the default name. | The length must not exceed 1024 bytes. | |
type |
Query type | STREAMING or ANALYTICS |
The default value is ANALYTICS . |
|
text |
Query text | String | Required | The length must be from 1 to 102400 bytes. |
description |
Query description | The default value is an empty string. | The length must not exceed 10240 bytes. |
Response
If successful, the HTTP code 200 and query ID are returned.
{
"id": "string"
}
Field | Description | Comment |
---|---|---|
Id |
ID of the created query | Required |
Example
Query:
curl -X 'POST' \
'https://api.yandex-query.cloud.yandex.net/api/fq/v1/queries?project=b1gaue5b382m********' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"name": "Test query",
"type": "ANALYTICS",
"text": "select 1",
"description": ""
}'
Response:
{
"id": "csqugo80f0l3********"
}