SESSIONS_BY_PROJECT view

TheINFORMATION_SCHEMA.SESSIONS_BY_PROJECT view contains real-timemetadata about all BigQuery sessions in the current project.

Note: The view namesINFORMATION_SCHEMA.SESSIONS andINFORMATION_SCHEMA.SESSIONS_BY_PROJECT are synonymous andcan be used interchangeably.

Required permissions

To query theINFORMATION_SCHEMA.SESSIONS_BY_PROJECT view, you needthebigquery.jobs.listAll Identity and Access Management (IAM) permission for the project.Each of the following predefined IAM roles includes therequired permission:

  • Project Owner
  • BigQuery Admin

For more information about BigQuery permissions, seeAccess control with IAM.

Schema

When you query theINFORMATION_SCHEMA.SESSIONS_BY_* views, the query resultscontain one row for each BigQuery session.

TheINFORMATION_SCHEMA.SESSIONS_BY_* view has the following schema:

Note: The underlying data is partitioned by thecreation_time column andclustered byproject_id anduser_email.
Column nameData typeValue
creation_timeTIMESTAMP (Partitioning column) Creation time of this session. Partitioning is based on the UTC time of this timestamp.
expiration_timeTIMESTAMP (Partitioning column) Expiration time of this session. Partitioning is based on the UTC time of this timestamp.
is_activeBOOL Is the session is still active?TRUE if yes, otherwiseFALSE.
last_modified_timeTIMESTAMP (Partitioning column) Time when the session was last modified. Partitioning is based on the UTC time of this timestamp.
project_idSTRING(Clustering column) ID of the project.
project_numberINTEGERNumber of the project.
session_idSTRINGID of the session. For example,bquxsession_1234.
user_emailSTRING (Clustering column) Email address or service account of the user who ran the session.

For stability, we recommend that you explicitly list columns in your information schema queries instead ofusing a wildcard (SELECT *). Explicitly listing columns prevents queries frombreaking if the underlying schema changes.

Data retention

This view contains currently running sessions and the history of sessionscompleted in the past 180 days.

Scope and syntax

Queries against this view must include aregion qualifier.If you do not specify a regional qualifier, metadata is retrieved from allregions. The following table explains the region scope for this view:

View nameResource scopeRegion scope
[PROJECT_ID.]`region-REGION`.INFORMATION_SCHEMA.SESSIONS_BY_PROJECTProject levelREGION
Replace the following:
  • Optional:PROJECT_ID: the ID of your Google Cloud project. If not specified, the default project is used.
  • REGION: anydataset region name. For example,`region-us`.

    Note: You must usea region qualifier to queryINFORMATION_SCHEMA views. The location of the query execution must match the region of theINFORMATION_SCHEMA view.

Example

To run the query against a project other than your default project, add theproject ID in the following format:

`PROJECT_ID`.`region-REGION_NAME`.INFORMATION_SCHEMA.SESSIONS_BY_PROJECT
For example,`myproject`.`region-us`.INFORMATION_SCHEMA.SESSIONS_BY_PROJECT.The following example lists all users or service accounts that created sessionsfor a given project within the last day:

SELECTDISTINCT(user_email)ASuserFROM`region-us`.INFORMATION_SCHEMA.SESSIONS_BY_PROJECTWHEREis_active=trueANDcreation_time>=TIMESTAMP_SUB(CURRENT_TIMESTAMP(),INTERVAL1DAY);
Note:INFORMATION_SCHEMA view names are case-sensitive.

The result is similar to the following:

+--------------+| user         |+--------------+| abc@xyz.com  |+--------------+| def@xyz.com  |+--------------+

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.