run_date
run_time
parameter in the following format: %Y%m%d
; for example, 20180101. This format is compatible with ingestion-time partitioned tables.Cloud Storage, Blob Storage, and Amazon S3 transfers support runtime parameters in the destination table name by using a templating syntax.
The templating syntax supports basic string templating and time offsetting. Parameters are referenced in the following formats:
{run_date}
{run_time[+\-offset]|"time_format"}
Parameter | Purpose |
---|---|
run_date | This parameter is replaced by the date in format YYYYMMDD . |
run_time | This parameter supports the following properties:
|
'\{' and '\}'
."YYYY|MM|DD"
, you can escape them in the format string as: '\"'
or '\|'
.run_time (UTC) | Templated parameter | Output destination table name |
---|---|---|
2018-02-15 00:00:00 | mytable | mytable |
2018-02-15 00:00:00 | mytable_{run_time|"%Y%m%d"} | mytable_20180215 |
2018-02-15 00:00:00 | mytable_{run_time+25h|"%Y%m%d"} | mytable_20180216 |
2018-02-15 00:00:00 | mytable_{run_time-1h|"%Y%m%d"} | mytable_20180214 |
2018-02-15 00:00:00 | mytable_{run_time+1.5h|"%Y%m%d%H"} or mytable_{run_time+90m|"%Y%m%d%H"} | mytable_2018021501 |
2018-02-15 00:00:00 | {run_time+97s|"%Y%m%d"}_mytable_{run_time+97s|"%H%M%S"} | 20180215_mytable_000137 |
There are two types of partitioned tables in BigQuery:
TIMESTAMP
or DATE
column.If the destination table is partitioned on a column, you identify the partitioning column when you create the destination table and specify its schema. Learn more about creating column-based partitioned tables in Creating and using partitioned tables.
mytable
mytable$YYYYMMDD
mytable
TIMESTAMP
or DATE
column when you create the table's schema.The following examples show ways to combine the wildcard character and parameters for common use cases. Assume the table's name is mytable
and the run_time
is 2018-02-15 00:00:00
(UTC) for all examples.
This use case applies to loading new files from a Cloud Storage, Blob Storage, or Amazon S3 bucket into a non-partitioned table. This example uses a wildcard in the URI or data path and uses an ad hoc refresh transfer to pick up new files.
Data source | Source URI or data path | Destination table name |
---|---|---|
Cloud Storage | gs://bucket/*.csv | mytable |
Amazon S3 | s3://bucket/*.csv | mytable |
Blob Storage | *.csv | mytable |
In this case, all data in the specified URI or data path is transferred to a table partitioned by today's date. In a refresh transfer, this configuration picks up files added since the last load and adds them to a particular partition.
Data source | Source URI or data path | Parameterized destination table name | Evaluated destination table name |
---|---|---|---|
Cloud Storage | gs://bucket/*.csv | mytable${run_time|"%Y%m%d"} | mytable$20180215 |
Amazon S3 | s3://bucket/*.csv | mytable${run_time|"%Y%m%d"} | mytable$20180215 |
Blob Storage | *.csv | mytable${run_time|"%Y%m%d"} | mytable$20180215 |
This use case transfers today's data into a table partitioned on today's date. This example also applies to a refresh transfer that retrieves newly added files that match a certain date and loads the data into the corresponding partition.
Data source | Parameterized URI or data path | Parameterized destination table name | Evaluated URI or data path | Evaluated destination table name |
---|---|---|---|---|
Cloud Storage | gs://bucket/events-{run_time|"%Y%m%d"}/*.csv | mytable${run_time|"%Y%m%d"} | gs://bucket/events-20180215/*.csv | mytable$20180215 |
Amazon S3 | s3://bucket/events-{run_time|"%Y%m%d"}/*.csv | mytable${run_time|"%Y%m%d"} | s3://bucket/events-20180215/*.csv | mytable$20180215 |
Blob Storage | events-{run_time|"%Y%m%d"}/*.csv | mytable${run_time|"%Y%m%d"} | events-20180215/*.csv | mytable$20180215 |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-04-17 UTC.