System variables in BigQuery are special types of variables available in scripts (multi-statement queries) that allow users to read and sometimes write query metadata during execution. These variables can be used to set or retrieve information, similar to user-defined procedural language variables.
Examples of System Variables
@@query_label: Read/write query labels to group queries.@@time_zone: Read/write default time zone.@@script.job_id: Job ID of the current job.
Below is a list of all supported system variables in BigQuery, sourced from the documentation.
| Name | Type | Access | Description |
|---|---|---|---|
@@current_job_id |
STRING | Read-only | Job ID of the currently executing job. |
@@dataset_id |
STRING | Read and write | ID of the default dataset in the current project. |
@@dataset_project_id |
STRING | Read and write | ID of the default project used when one is not specified for a dataset. |
@@last_job_id |
STRING | Read-only | Job ID of the most recent job to execute in the current multi-statement query. |
@@project_id |
STRING | Read-only | ID of the project used to execute the current query. |
@@query_label |
STRING | Read and write | Query label to associate with query jobs in the current multi-statement query or session. |
@@row_count |
INT64 | Read-only | Number of rows modified, inserted, or deleted by the previous DML statement. |
@@script.bytes_billed |
INT64 | Read-only | Total bytes billed so far in the currently executing multi-statement query job. |
@@script.bytes_processed |
INT64 | Read-only | Total bytes processed so far in the currently executing multi-statement query job. |
@@script.creation_time |
TIMESTAMP | Read-only | Creation time of the currently executing multi-statement query job. |
@@script.job_id |
STRING | Read-only | Job ID of the currently executing multi-statement query job. |
@@script.num_child_jobs |
INT64 | Read-only | Number of currently completed child jobs. |
@@script.slot_ms |
INT64 | Read-only | Number of slot milliseconds used so far by the script. |
@@session_id |
INT64 | Read-only | ID of the session that the current query is associated with. |
@@time_zone |
STRING | Read and write | Default time zone to use in time zone-dependent SQL functions. |
Additional Information
- EXCEPTION System Variables: These can be used during the execution of a multi-statement query. For more details, refer to the procedural language statement
BEGIN...EXCEPTION.
These system variables enhance the ability to manage and retrieve metadata during query execution, making it easier to handle complex queries and scripts in BigQuery.










