

# sessions

The `sessions` system table contains one aggregated row for each interactive session that reaches a terminal state, such as terminated or failed. It covers Amazon EMR on EC2, Amazon EMR on EKS, and Amazon EMR Serverless in your account and Region. To follow a session through its state changes, see [session\_lifecycle](emr-system-table-session-lifecycle.md).

## Table location
<a name="emr-system-table-sessions-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 `sessions` table.

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

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

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


| Column | Type | Description | 
| --- | --- | --- | 
| session\_key | string | Unique identifier for a single session, the same on every event belonging to that session. | 
| account\_id | string | The AWS account that owns the session. | 
| region\_name | string | The AWS Region where the session ran. | 
| platform\_enum | string | Compute platform that ran the session. Valid values are emr\_ec2, emr\_eks, and emr\_serverless. | 
| compute\_id | string | Identifier of the compute resource that ran the session. | 
| compute\_arn | string | ARN of the compute named in compute\_id. | 
| session\_id | string | Identifier the platform assigned to this session. | 
| session\_arn | string | Full ARN of the session, as returned by the service API. | 
| session\_name | string | Name that you gave the session when you submitted it. Null if you created the session without a name. | 
| session\_type\_enum | string | Kind of session the row describes. Valid values are spark, spark\_connect, livy, jupyter\_enterprise\_gateway, trino, and hive. | 
| engine\_enum | string | Processing engine that ran the session. Valid values are spark, trino, and hive. | 
| release\_label | string | The Amazon EMR release used by the compute resource. | 
| application\_conf\_json | string (JSON) | The session's submitted application configuration. Null when the session ran with the compute resource's own configuration. | 
| monitoring\_conf\_json | string (JSON) | The session's submitted monitoring configuration. Null when monitoring was not configured for the session. | 
| idle\_timeout\_minutes | long | How long the session may stay idle before the platform terminates it. | 
| client\_request\_token | string | Idempotency token the caller supplied on the create-session request. Null when the caller supplied no token. | 
| submitter\_arn | string | ARN of the IAM user or role that submitted the session. Null if you created the session without a runtime role. | 
| execution\_role\_arn | string | ARN of the IAM role the session used while running. Null when the session ran with the compute resource's own permissions. | 
| final\_state\_enum | string | The session's state exactly as the platform reports it, matching what you would see in the service console or API. | 
| state\_reason\_message | string | Readable explanation of why the session is in its current state. Null when the platform reports no reason for the final state. | 
| error\_category | string | Broad category of a failure. Null when the session has not failed. | 
| creation\_time | timestamp | Time that you created the session. | 
| start\_time | timestamp | When the session first became available to accept work. Null when the session failed while starting. | 
| termination\_request\_time | timestamp | When termination of the session was requested. Null when no termination has been requested. | 
| end\_time | timestamp | When the session ended, whether it terminated normally or failed. | 
| queue\_duration | long | How long the session waited before it started running, in milliseconds. On Amazon EMR Serverless this excludes provisioning time. Null on Amazon EMR on EC2 and Amazon EMR on EKS when the session never started, and on Amazon EMR Serverless when the session was never queued. | 
| execution\_duration | long | How long the session spent running, in milliseconds, excluding time spent waiting. Null when the session never started. | 
| session\_duration | long | Total time from creation to end, in milliseconds. | 
| requested\_capacity\_json | string (JSON) | Spark capacity the session requested, projected from its submitted configuration. Null when the session requested no explicit capacity. | 
| vcpu\_seconds | double | Allocated vCPU-seconds. Null for Amazon EMR on EC2 and Amazon EMR on EKS. | 
| memory\_gb\_seconds | double | Allocated memory. Null for Amazon EMR on EC2 and Amazon EMR on EKS. | 
| 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-sessions-examples"></a>

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

### Sessions by type and final state
<a name="emr-system-table-sessions-examples-by-type"></a>

The following SQL query groups sessions by platform, type, and final state over the past 7 days, with a count and average duration for each group.

```sql
SELECT platform_enum, session_type_enum, final_state_enum,
       COUNT(*) AS sessions,
       AVG(session_duration) / 60000.0 AS avg_minutes
FROM "s3tablescatalog/aws-emr"."metadata"."sessions"
WHERE end_time >= current_timestamp - INTERVAL '7' DAY
GROUP BY platform_enum, session_type_enum, final_state_enum
```

### Failed sessions in the past 24 hours, with reason
<a name="emr-system-table-sessions-examples-failed"></a>

The following SQL query lists sessions that failed in the past 24 hours and the reason reported for each.

```sql
SELECT platform_enum, compute_id, session_id, session_name, final_state_enum,
       state_reason_message, end_time
FROM "s3tablescatalog/aws-emr"."metadata"."sessions"
WHERE end_time >= current_timestamp - INTERVAL '1' DAY
  AND final_state_enum = 'FAILED'
ORDER BY end_time DESC
```