System variables reference

BigQuery supports the following system variables for multi-statement queries or within sessions. You can use system variables to check information during execution of a multi-statement query. System variables can be used similarly to user-created procedural language variables.

Name Type Description
@@current_job_id STRING (Read-only) Job ID of the currently executing job. In the context of a multi-statement query, this returns the job responsible for the current statement, not the entire multi-statement query.
@@dataset_id STRING ID of the default dataset in the current project. This ID is used when a dataset is not specified for a project in the query. You can use the SET statement to assign @@dataset_id to another dataset ID in the current project. The system variables @@dataset_project_id and @@dataset_id can be set and used together.
@@dataset_project_id STRING ID of the default project that's used when one is not specified for a dataset used in the query. If @@dataset_project_id is not set, or if it is set to NULL, the query-executing project (@@project_id) is used. You can use the SET statement to assign @@dataset_project_id to another project ID. The system variables @@dataset_project_id and @@dataset_id can be set and used together.
@@last_job_id STRING (Read-only) Job ID of the most recent job to execute in the current multi-statement query, not including the current one. If the multi-statement query contains CALL statements, this job may have originated in a different procedure.
@@project_id STRING (Read-only) ID of the project used to execute the current query. In the context of a procedure, @@project_id refers to the project that is running the multi-statement query, not the project which owns the procedure.
@@query_label STRING Query label to associate with query jobs in the current multi-statement query or session. If set in a query, all subsequent query jobs in the script or session will have this label. If not set in a query, the value for this system variable is NULL. For an example of how to set this system variable, see Associate jobs in a session with a label.
@@row_count INT64 (Read-only) If used in a multi-statement query and the previous statement is DML, specifies the number of rows modified, inserted, or deleted, as a result of that DML statement. If the previous statement is a MERGE statement, @@row_count represents the combined total number of rows inserted, removed, and deleted. This value is NULL if not in a multi-statement query.
@@script.bytes_billed INT64 (Read-only) Total bytes billed so far in the currently executing multi-statement query job. This value is NULL if not in the job.
@@script.bytes_processed INT64 (Read-only) Total bytes processed so far in the currently executing multi-statement query job. This value is NULL if not in the job.
@@script.creation_time TIMESTAMP (Read-only) Creation time of the currently executing multi-statement query job. This value is NULL if not in the job.
@@script.job_id STRING (Read-only) Job ID of the currently executing multi-statement query job. This value is NULL if not in the job.
@@script.num_child_jobs INT64 (Read-only) Number of currently completed child jobs. This value is NULL if not in the job.
@@script.slot_ms INT64 (Read-only) Number of slot milliseconds used so far by the script. This value is NULL if not in the job.
@@session_id INT64 (Read-only) ID of the session that the current query is associated with.
@@time_zone STRING The default time zone to use in time zone-dependent SQL functions, when a time zone is not specified as an argument. @@time_zone can be modified by using a SET statement to any valid time zone name. At the start of each script, @@time_zone begins as “UTC”.

In addition to the system variables shown above, you can use EXCEPTION system variables during execution of a multi-statement query. For more information about the EXCEPTION system variables, see the procedural language statement BEGIN...EXCEPTION.