INFORMATION_SCHEMA.SESSIONS_BY_PROJECT view contains real-time
metadata about all BigQuery sessions in the current project.
To query the
INFORMATION_SCHEMA.SESSIONS_BY_PROJECT view, you need
bigquery.jobs.listAll Identity and Access Management (IAM) permission for the project.
Each of the following predefined IAM roles includes the
- Project Owner
- BigQuery Admin
For more information about BigQuery permissions, see Access control with IAM.
When you query the
INFORMATION_SCHEMA.SESSIONS_BY_* views, the query results
contain one row for each BigQuery session.
INFORMATION_SCHEMA.SESSIONS_BY_* view has the following schema:
|Column name||Data type||Value|
||(Partitioning column) Creation time of this session. Partitioning is based on the UTC time of this timestamp.|
||(Partitioning column) Expiration time of this session. Partitioning is based on the UTC time of this timestamp.|
Is the session is still active?
||(Partitioning column) Time when the session was last modified. Partitioning is based on the UTC time of this timestamp.|
||(Clustering column) ID of the project.|
||Number of the project.|
||ID of the session. For example,
||(Clustering column) Email address or service account of the user who ran the session.|
This view contains currently running sessions and the history of sessions completed in the past 180 days.
Scope and syntax
Queries against this view must include a region qualifier. If you do not specify a regional qualifier, metadata is retrieved from all regions. The following table explains the region scope for this view:
|View name||Resource scope||Region scope|
PROJECT_ID: the ID of your Cloud project. If not specified, the default project is used.
REGION: any dataset region name. For example,
To run the query against a project other than your default project, add the project ID in the following format:
`myproject`.`region-us`.INFORMATION_SCHEMA.SESSIONS_BY_PROJECT. The following example lists all users or service accounts that created sessions for a given project within the last day:
SELECT DISTINCT(user_email) AS user FROM `region-us`.INFORMATION_SCHEMA.SESSIONS_BY_PROJECT WHERE is_active = true AND creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY);
The result is similar to the following:
+--------------+ | user | +--------------+ | email@example.com | +--------------+ | firstname.lastname@example.org | +--------------+