Categories:

System Functions (System Information)

SYSTEM$GET_JOB_STATUS

Retrieves status as a Snowpark Container Services job.

See also:

Monitoring a job

Syntax

SYSTEM$GET_JOB_STATUS( <job_uuid> [ , <timeout_secs> ]  )
Copy

Arguments

Required:

job_uuid

Snowflake-assigned UUID of the job. See Usage Notes in the EXECUTE SERVICE topic for instructions on finding the UUID.

Optional:

timeout_secs

Number of seconds to wait for the job to reach a terminal state (DONE or FAILED) before returning the status. If the job does not reach the terminal state within the specified time, Snowflake returns the current state.

If not specified, Snowflake returns the current state immediately.

Default: 0 seconds

Returns

Returns status information in a JSON array with one JSON object for each job container. The JSON fields are:

  • status. Job container status. Currently supported status values include: PENDING, FAILED, DONE, and UNKNOWN.

  • message. Provides details about the specific status. For example, when the status is PENDING, this field describes why.

  • containerName. Container name.

  • instanceId. Job instance ID. For a job, this is always 0.

  • serviceName. Snowflake-assigned UUID of the job.

  • image. URL of the image that is running.

  • restartCount. Number of times Snowflake restarted the container. A higher restart count can indicate an unhealthy job. For example, if your job code crashes, the container can exit. Snowflake then tries to restart the container. In this case, to investigate, you can access the container log using these options:

    • Use the SYSTEM$GET_JOB_LOGS for live logs (the container is running).

    • Use event tables for persistent logs (useful when the container is no longer running).

  • startTime. Time when the container started.

Usage notes

Only the user who created the job can access the job status.

Examples

The following function retrieves the status of the specified job:

SELECT SYSTEM$GET_JOB_STATUS('01acc9da-0000-60e8-0000-0e9900201012');
Copy

Sample output:

[
  {
      "status":"DONE",
      "message":"Container finished",
      "containerName":"main",
      "instanceId":"0",
      "serviceName":"JOB_01ACC9DA000060E800000E9900201012",
      "image":"<account>.registry.snowflakecomputing.com/tutorial_db/data_schema/tutorial_repository/my_job_image:tutorial",
      "restartCount":0,
      "startTime":"2023-01-01T00:00:00Z"
  }
]
Copy