

# job\_lifecycle

The `job_lifecycle` system table contains one row for each job state change across Amazon EMR on EC2, Amazon EMR on EKS, and Amazon EMR Serverless in your account and Region. Each row records a single transition, so you can follow a job through its states from submission to a terminal state. States appear exactly as the service reports them. For one aggregated row for each finished job attempt, see [job\_runs](emr-system-table-job-runs.md).

## Table location
<a name="emr-system-table-job-lifecycle-location"></a>

You query system tables like any other tables in Amazon S3 Tables. The catalog name contains a slash and a hyphen, so you must enclose it in double quotation marks. The following SQL query uses the fully qualified name of the `job_lifecycle` table.

```sql
SELECT * FROM "s3tablescatalog/aws-emr"."metadata"."job_lifecycle" LIMIT 10
```

## Columns
<a name="emr-system-table-job-lifecycle-columns"></a>

The following table describes the columns in the `job_lifecycle` system table.


| Column | Type | Description | 
| --- | --- | --- | 
| job\_key | string | Unique identifier for a single job, the same on every event belonging to that job. | 
| job\_name | string | Name that you gave the job when you submitted it. Null if you submitted the job without a name. | 
| job\_id | string | Identifier the platform assigned to this job. | 
| account\_id | string | The AWS account that owns the job. | 
| region\_name | string | The AWS Region where the job ran. | 
| attempt\_number | int | Retry attempt number. | 
| event\_time | timestamp | When this lifecycle event occurred. | 
| engine\_enum | string | Processing engine that ran the job. Valid values are spark, hive, trino, custom\_jar, and other. | 
| job\_driver\_type\_enum | string | Kind of workload the job represents. Valid values are spark, pyspark, spark\_submit\_job, spark\_sql\_job, hive, hive\_cli, stream, trino\_session, and custom\_jar. | 
| release\_label | string | The Amazon EMR release used by the compute resource. Null for clusters launched with an AMI version rather than a release label. | 
| state\_enum | string | The job's state exactly as the platform reports it, matching what you would see in the service console or API. | 
| platform\_enum | string | Compute platform that ran the job. Valid values are emr\_ec2, emr\_eks, and emr\_serverless. | 
| compute\_id | string | Identifier of the compute resource that ran the job. | 
| submitter\_arn | string | ARN of the IAM user or role that submitted the job. Null if you submitted the job without a runtime role. | 
| creation\_time | timestamp | Time that you created the job. | 
| start\_time | timestamp | When the job began running. Null when the job never started, including a job cancelled while queued. | 
| is\_terminal | boolean | True when the job has finished and no further events will be recorded for it. | 
| state\_reason\_message | string | Readable explanation of why the job is in its current state. Null for platforms that don't report this message. | 
| schema\_version | string | Version identifier for this row's field set. | 
| ingest\_time | timestamp | When this row was written to the table. | 

## Example queries
<a name="emr-system-table-job-lifecycle-examples"></a>

The following examples show common queries against the `job_lifecycle` table.

### Timeline of one job across attempts
<a name="emr-system-table-job-lifecycle-examples-timeline"></a>

The following SQL query traces one job through its state changes across attempts. Replace the following value.
+ `{{job-key}}` is the key of the job you want to trace.

```sql
SELECT event_time, attempt_number, state_enum, is_terminal, state_reason_message
FROM "s3tablescatalog/aws-emr"."metadata"."job_lifecycle"
WHERE event_time >= current_timestamp - INTERVAL '7' DAY
  AND job_key = '{{job-key}}'
ORDER BY event_time
```

### Jobs whose latest recorded state is not terminal
<a name="emr-system-table-job-lifecycle-examples-running"></a>

The following SQL query returns jobs whose most recent recorded state isn't terminal.

```sql
WITH latest AS (
  SELECT *,
         ROW_NUMBER() OVER (
           PARTITION BY job_key, attempt_number
           ORDER BY event_time DESC, ingest_time DESC) AS rn
  FROM "s3tablescatalog/aws-emr"."metadata"."job_lifecycle"
  WHERE event_time >= current_timestamp - INTERVAL '2' DAY)
SELECT platform_enum, compute_id, job_id, job_name, state_enum, event_time
FROM latest
WHERE rn = 1 AND NOT is_terminal
```

This query reflects the latest delivered transition, which can lag by the delivery delay. For live status, use the platform console or the `DescribeStep`, `DescribeJobRun`, or `GetJobRun` operations.