System variables in BigQuery

Today's quick post is about system variables in BigQuery. What are they?

They are a special type of variables, available in scripts (multi-statement queries). You can use them to read (and sometimes write) query metadata during query execution.

Here's a couple of examples:
- @@query_label - read/write query labels, making easier for you to group your queries based on they are used for
- @@time_zone - read/write default time zone to use
- @@script.job_id - the job id of the current job

Check out below an example with slot_ms (returns slot time in millis), bytes_billed and creation_date.

No alt text provided for this image

Found it useful? Subscribe to my Analytics newsletter at notjustsql.com.