Executing a Script

Function

This API is used to execute specified scripts, including DWS SQL, DLI SQL, Hive SQL, Spark SQL, RDS SQL, Flink SQL, and Presto SQL scripts. A script instance is generated each time the script is executed. You can obtain script execution results using the API for querying script execution results. This API is described in Querying the Execution Result of a Script Instance.

URI

  • URI format

    POST /v1/{project_id}/scripts/{script_name}/execute

  • Parameter description
    Table 1 URI parameter description

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

    script_name

    Yes

    String

    Script name.

Request Message

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

workspace

No

String

Workspace ID.

  • If this parameter is not set, data in the default workspace is queried by default.
  • If you need to query data in other workspaces, this header must be carried.
Table 3 Parameter description

Parameter

Mandatory

Type

Description

params

No

Map<String,String>

Script parameter. If a parameter is defined in the script, the parameter value is carried in the params. By default, this parameter is left blank.

Script parameters refer to the parameters in the script content, as shown in the following figure:

Response Message

Table 4 Parameter description

Parameter

Mandatory

Type

Description

instanceId

Yes

String

ID of the instance for executing the script. To obtain the execution result, refer to the instructions in Querying the Execution Result of a Script Instance.

Example

  • Request
    POST /v1/b384b9e9ab9b4ee8994c8633aabc9505/scripts/rds_sql/execute
    {
    "params":{"tableVar":"citys",
    "time":"2019-07-25"}
    }
  • Success response

    HTTP status code 200

    {
    "instanceId": "a1ad-448a-9d56-4154193d49c5"
    }
  • Failure response

    HTTP status code 400

    {
        "error_code":"DLF.6201",
        "error_msg":"The script does not exist."
    }

Status Code

For details about status codes, see Status Codes.