Preview dashboard chart SQL¶
Execute a chart SQL preview, returning query results without saving the chart.
POST $CLOUDSIGMA_API_BASE/data-dashboards/{dashboard_id}/preview
Before you call¶
Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region. First select the data dashboard to preview SQL in Query Data Kanban List.
Prepare personal access token and target workspace ID that can access the target workspace.
Request body¶
curl -X POST "$CLOUDSIGMA_API_BASE/data-dashboards/$DASHBOARD_ID/preview" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"sql_text": "SELECT * FROM analytics.daily_sales LIMIT 10"
}'
Replace the credentials and IDs in the example with actual values. The example uses analytics.daily_sales. Please first add the actually queryable table to the current Kanban source, or change the SQL to the currently saved source table.
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Data dashboard ID. |
Request body
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
SQL to preview. Cannot be empty. |
|
string |
No |
Chart ID. |
sql_text must refer to the actual saved table of the current Kanban board. The current identity must have table query and database SQL permissions. When multiple databases are involved, use database qualified names as required. SELECT 1 The source table is not referenced and cannot be used for this interface.
You can fill in chart_id in the current dashboard and use the database of this chart. When omitted, the current source library is used. When multiple databases are involved, the library name is qualified according to rules. Regardless of whether to fill in the ID, the source scope and actual data permissions must be met.
Successful response¶
{
"code": "OK",
"msg": "OK",
"data": {
"query_id": "query-001",
"db_name": "analytics",
"statement_id": "stmt-001",
"status": "success",
"limit": 1000,
"total": 1,
"columns": [
{
"name": "value",
"type": "BIGINT"
}
],
"result": [
[
{
"String": "1",
"Valid": true
}
]
],
"elapsed_ms": 12,
"truncated": false
}
}
Field |
Type |
Description |
|---|---|---|
|
string |
Query ID. |
|
string |
The name of the database where SQL is executed. |
|
string |
Statement ID. |
|
string |
Query status. |
|
string |
Query failure reason. Returned when the query fails. |
|
integer |
The starting offset of this result. Currently it is 0, and it is omitted when the value is 0. |
|
integer |
The maximum number of rows returned for this preview is currently 1000. |
|
integer |
The maximum number of rows returned this time is 1000. |
|
array of object |
Result column. |
|
string |
Name. |
|
string |
type. |
|
array |
Result data. |
|
integer |
Number of rows affected. |
|
object or null |
Whether it is an empty collection. |
|
string |
Description of results. |
|
integer |
This preview takes time, in milliseconds. |
|
boolean |
Truncate mark. The current preview chain has a false negative limit, and the result cannot be judged based on false alone. |
Error response¶
The following example corresponds to HTTP 400.
{
"code": "ErrParamInvalid",
"msg": "Bad Request"
}
Field |
Type |
Description |
|---|---|---|
|
string |
Error code, such as |
|
string |
HTTP status description, such as |