Preview dashboard chart SQL

Execute a chart SQL preview, returning query results without saving the chart.

HTTP
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

Shell
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

dashboard_id

string

Yes

Data dashboard ID.

Request body

Field

Type

Required

Description

sql_text

string

Yes

SQL to preview. Cannot be empty.

chart_id

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

JSON
{
  "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

data.query_id

string

Query ID.

data.db_name

string

The name of the database where SQL is executed.

data.statement_id

string

Statement ID.

data.status

string

Query status.

data.err_msg

string

Query failure reason. Returned when the query fails.

data.offset

integer

The starting offset of this result. Currently it is 0, and it is omitted when the value is 0.

data.limit

integer

The maximum number of rows returned for this preview is currently 1000.

data.total

integer

The maximum number of rows returned this time is 1000.

data.columns

array of object

Result column.

data.columns[].name

string

Name.

data.columns[].type

string

type.

data.result

array

Result data.

data.rows_affected

integer

Number of rows affected.

data.empty_set

object or null

Whether it is an empty collection.

data.empty_set.msg

string

Description of results.

data.elapsed_ms

integer

This preview takes time, in milliseconds.

data.truncated

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.

JSON
{
  "code": "ErrParamInvalid",
  "msg": "Bad Request"
}

Field

Type

Description

code

string

Error code, such as ErrParamInvalid or ErrDataDashboardNotFound.

msg

string

HTTP status description, such as Bad Request or Not Found.

Last updated on