# DESCRIBE QUERY EVENTS

## Syntax

```sql
DESCRIBE QUERY EVENTS [query_id | query_name[:query_version]];
```

## Description

This command provides a list of events for a [Streaming or Continuous Query](https://docs.deltastream.io/overview/core-concepts/queries#_streaming_or_continuous_query) created in the current [Organization](https://docs.deltastream.io/overview/core-concepts/access-control#organiation).

See [Query](https://docs.deltastream.io/overview/core-concepts/queries) on how streaming queries operate in DeltaStream.

The Query is visible only if the current role has `USAGE` privileges.

### Arguments <a href="#parameters" id="parameters"></a>

#### query\_id

This is the unique identifier of the query to describe. See [LIST QUERIES](https://docs.deltastream.io/reference/sql-syntax/command/list-queries) to find out how to list all queries to which the user has access. The first column (`ID`) in the response corresponds with the `query_id`.

#### query\_name

This is the name of the Query to describe. See [LIST QUERIES](https://docs.deltastream.io/reference/sql-syntax/command/list-queries) to find out how to list all queries to which the user has access. The column (`Name`) in the response corresponds with the `query_name`. The `query_version` property disambiguates between multiple queries with the same name.

#### query\_version

This is the version of the query to describe. See [LIST QUERIES](https://docs.deltastream.io/reference/sql-syntax/command/list-queries) to find out how to list all queries to which the user has access. The column (`Version`) in the response corresponds with the `query_version`. If `query_name` is provided without a `query_version`, the system uses `query_version`.

## Examples

#### Show query events when running and stopped

```bash
demodb.public/demostore# DESCRIBE QUERY EVENTS 5b9ba120-bb59-4c95-82c5-6ee0f78dc75e;
+-------------------------------+----------------------+---------+-----------+
|           Created At          |        Actor         |   Type  |  Messages |
+-------------------------------+----------------------+---------+-----------+
| 2024-08-09 15:45:32 +0000 UTC | system               | running |           |
+-------------------------------+----------------------+---------+-----------+
| 2024-08-09 15:45:01 +0000 UTC | delta@deltastream.io | created |           |
+-------------------------------+----------------------+---------+-----------+

demodb.public/demostore# DESCRIBE QUERY EVENTS demoquery:1;
+-------------------------------+----------------------+---------+-----------+
|           Created At          |        Actor         |   Type  |  Messages |
+-------------------------------+----------------------+---------+-----------+
| 2024-08-09 15:45:32 +0000 UTC | system               | running |           |
+-------------------------------+----------------------+---------+-----------+
| 2024-08-09 15:45:01 +0000 UTC | delta@deltastream.io | created |           |
+-------------------------------+----------------------+---------+-----------+

demodb.public/demostore# DESCRIBE QUERY EVENTS 24f5a97b-97e9-40eb-8dbf-431b96474972;
+-------------------------------+----------------------+---------------------+-----------+
|           Created At          |        Actor         |         Type        |  Messages |
+-------------------------------+----------------------+---------------------+-----------+
| 2024-08-09 15:47:57 +0000 UTC | system               | terminated          |           |
+-------------------------------+----------------------+---------------------+-----------+
| 2024-08-09 15:47:40 +0000 UTC | delta@deltastream.io | terminate_requested |           |
+-------------------------------+----------------------+---------------------+-----------+
| 2024-08-09 15:45:32 +0000 UTC | system               | running             |           |
+-------------------------------+----------------------+---------------------+-----------+
| 2024-08-09 15:45:01 +0000 UTC | delta@deltastream.io | created             |           |
+-------------------------------+----------------------+---------------------+-----------+

demodb.public/demostore# DESCRIBE QUERY EVENTS demoquery:1;
+-------------------------------+----------------------+---------------------+-----------+
|           Created At          |        Actor         |         Type        |  Messages |
+-------------------------------+----------------------+---------------------+-----------+
| 2024-08-09 15:47:57 +0000 UTC | system               | terminated          |           |
+-------------------------------+----------------------+---------------------+-----------+
| 2024-08-09 15:47:40 +0000 UTC | delta@deltastream.io | terminate_requested |           |
+-------------------------------+----------------------+---------------------+-----------+
| 2024-08-09 15:45:32 +0000 UTC | system               | running             |           |
+-------------------------------+----------------------+---------------------+-----------+
| 2024-08-09 15:45:01 +0000 UTC | delta@deltastream.io | created             |           |
+-------------------------------+----------------------+---------------------+-----------+
```

#### Show events for a query that has been rescheduled

You can reschedule queries for any number of reasons. Typically you reschedule a query if a you must move it to another node.

```bash
demodb.public/demostore# DESCRIBE QUERY EVENTS demoquery:1;
+-------------------------------+----------------------+---------------------+-----------+
|           Created At          |        Actor         |         Type        |  Messages |
+-------------------------------+----------------------+---------------------+-----------+
| 2024-08-09 15:47:57 +0000 UTC | system               | running             |           |
+-------------------------------+----------------------+---------------------+-----------+
| 2024-08-09 15:47:40 +0000 UTC | system               | rescheduled         |           |
+-------------------------------+----------------------+---------------------+-----------+
| 2024-08-09 15:45:32 +0000 UTC | system               | running             |           |
+-------------------------------+----------------------+---------------------+-----------+
| 2024-08-09 15:45:01 +0000 UTC | delta@deltastream.io | created             |           |
+-------------------------------+----------------------+---------------------+-----------+
```

The following example shows an errored query:

```bash
testdb.public/internal_stage# DESCRIBE QUERY EVENTS 142ecf31-bc8d-496b-bd0b-28ebb4a8757e;
+-------------------------------+----------------------+---------------------+------------------+
|           Created At          |        Actor         |         Type        |      Messages    |
+-------------------------------+----------------------+---------------------+------------------+
| 2024-08-09 15:46:32 +0000 UTC | system               | errored             |  <error_message> |
+-------------------------------+----------------------+---------------------+------------------+
| 2024-08-09 15:45:32 +0000 UTC | system               | running             |                  |
+-------------------------------+----------------------+---------------------+------------------+
| 2024-08-09 15:45:01 +0000 UTC | delta@deltastream.io | created             |                  |
+-------------------------------+----------------------+---------------------+------------------+
```
