queries
Description
Exposes metadata about all streaming queries in the organization — both active and terminated. Useful for auditing query history, checking current state, or finding errored queries. Rows are filtered to queries the current role has USAGE privileges on.
Note current_state is the live observed state; intended_state is what was requested.
Syntax
SELECT ... FROM deltastream.sys."queries";Columns
id
VARCHAR
No
Unique identifier of the query.
organization_id
VARCHAR
No
The unique identifier of the organization this resource belongs to.
owner
VARCHAR
No
The role that owns this resource.
name
VARCHAR
Yes
Name of the query, if it was created as a named query.
version
INTEGER
Yes
Version number of the named query.
sql
VARCHAR
No
The SQL statement of the query.
is_interactive
BOOLEAN
No
Whether the query is an interactive (sandbox) query.
intended_state
VARCHAR
No
The state the query has been instructed to be in. One of running, stopped.
current_state
VARCHAR
No
The observed current state of the query. One of running, stopped, errored, terminated.
created_by_role
VARCHAR
No
The role that created this resource.
created_by_role_deleted
BOOLEAN
No
Whether the creating role has since been deleted.
created_by
VARCHAR
No
The user that created this resource.
created_at
TIMESTAMP_LTZ
No
Timestamp when this resource was created.
updated_by_role
VARCHAR
No
The role that last updated this resource.
updated_by_role_deleted
BOOLEAN
No
Whether the last updating role has since been deleted.
updated_by
VARCHAR
No
The user that last updated this resource.
updated_at
TIMESTAMP_LTZ
No
Timestamp when this resource was last updated.
deleted_at
TIMESTAMP_LTZ
Yes
Timestamp when the query was terminated and deleted, if applicable.
Examples
List all queries:
Filter to only running queries:
Find errored queries:
See Also
Last updated

