Obtains the status of all the code blocks for a Spark session.


OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes ListSparkStatements

The operation that you want to perform. Set the value to ListSparkStatements.

JobId String Yes j202106071620hangzhou00000000001

The ID of the Spark job.

Response parameters

Parameter Type Example Description
RequestId String C2AB7692-B9EF-4A50-BCFF-0DC5B6F080E8

The unique ID of the request.

Statements Array of Statements

The execution results of the code block.

Code String print(2 + 2)

The code block that is executed.

CompletedTime Long 1623033200754

The timestamp when the execution of the code block was completed, in milliseconds.

Id Integer 2

The unique ID of the code block.

Output String {\"status\":\"ok\",\"execution_count\":1,\"data\":{\"text/plain\":\"4\"}}

The execution result of the code block, which is a JSON string. It contains the following information:

  • status: the status of the code block.
  • execution_count: the number of rows in the code block that are executed.
  • data: the execution result of the code block.
Progress Float 1

The current execution progress. It is a floating-point number, which represents the progress percentage. The value 1 indicates 100%.

StartedTime Long 1623033200750

The timestamp when the code block started to execute, in milliseconds.

State String running

The status of the code block. Valid values:

  • waiting: The code block is to be executed.
  • running: The code block is being executed.
  • available: The execution of the code block is completed.
  • error: The execution of the code block fails.
  • cancelling: The execution of the code block attempts to be terminated.
  • cancelled: The execution of the code block is terminated.


Sample requests

&<Common request parameters>

Sample success responses

XML format

    <Output>{"status":"ok","execution_count":0,"data":{"text/plain":"&lt;pyspark.sql.session.SparkSession object at 0x7f5e4a550390&gt;"}}</Output>
    <Code>print(2 + 2)

JSON format

  "RequestId": "C2AB7692-B9EF-4A50-BCFF-0DC5B6F080E8",
  "Statements": [
      "Progress": 1,
      "CompletedTime": 1623033200078,
      "State": "available",
      "Output": "{\"status\":\"ok\",\"execution_count\":0,\"data\":{\"text/plain\":\"<pyspark.sql.session.SparkSession object at 0x7f5e4a550390>\"}}",
      "StartedTime": 1623033200077,
      "Id": 0,
      "Code": "spark"
      "Progress": 1,
      "CompletedTime": 1623033200754,
      "State": "available",
      "Output": "{\"status\":\"ok\",\"execution_count\":1,\"data\":{\"text/plain\":\"4\"}}",
      "StartedTime": 1623033200753,
      "Id": 1,
      "Code": "print(2 + 2)\n"

Error codes

For a list of error codes, visit the API Error Center.