Use BigQuery clones for bounded development work
In brief
Use a writable BigQuery clone when a test needs the source data's distribution or history. Use a small fixture when it reproduces the problem.
- Check who can read the destination dataset and set an expiration.
- Changes to the source can increase storage charges even for an untouched clone.
A developer needs to test an incremental update against a large orders table. Copying a few clean rows would miss the skew, duplicates, and historical combinations that make the change risky. A full exported copy would take more preparation than the experiment deserves. A BigQuery table clone can provide writable state without initially charging for another full set of shared data.
We’d use a clone for a named experiment with a short lifetime, approved readers, and a reason to need representative data. When a fixture can reproduce the defect, we’d use a small, hand-built fixture instead.
Even with cheap clones, we wouldn’t give every development environment a permanent copy of production.
Decide what the experiment must preserve
Write down what the experiment must observe. A join change may need rare key combinations, and a performance experiment realistic partition sizes and data distribution. A type conversion may only need a few boundary values. A small fixture expresses those more precisely than a large sample.
A table clone is writable and independent after creation: later data changes don’t propagate between it and its source. That suits repeatable comparisons, provided you keep an untouched control or can recreate the required source point. After the first mutation, the experimental table no longer represents the starting state.
For a test involving several tables, record their source versions and required relationship. Clones created by separate statements aren’t guaranteed to share a business cutoff. If the orders clone includes an order whose lines aren’t in the selected line-item version, the test may diagnose the fixture’s inconsistency instead of the proposed SQL change.
A clone also leaves out recent rows still in a streaming buffer. Views and external tables can’t be cloned at all. Check the source limitations before treating the clone as evidence about the newest ingestion behavior. Also check the fine-grained DML restrictions: a table with fine-grained DML enabled that has undergone an UPDATE, DELETE, or MERGE can’t be cloned afterward.
If the test only needs stable read access, a writable copy adds permissions the task doesn’t use. If developers shouldn’t receive the underlying records, give them an approved sanitized fixture instead.
Source activity can make an untouched clone expensive
Storage diverges from both directions. Clone writes can create billable data. Changes or deletions in the base table can also leave old data that only the clone still holds.
When several clones share that data, BigQuery charges it to the oldest of them. A developer who hasn’t run a single write can pick up storage charges because production changed.
A few changed business rows can cause much more storage to be rewritten. Automatic reclustering can make the oldest clone responsible for the old storage of an entire modified partition. A forecast based only on the rows the developer plans to update misses that effect.
Consider a simplified model with an invented block size: four shared blocks of 128 GiB each. The base table and two unchanged clones reference 512 GiB of unique blocks, though summing three full-equivalent table sizes would report 1,536 GiB. If the base replaces one block, the clones keep its old version while the base uses the new one. The model now holds 640 GiB.
How much of the source will be rewritten during the experiment’s lifetime? A three-day test against append-mostly history keeps little old storage alive. A three-week test spanning repeated full rebuilds of the source can keep most of it.
Keep the clone short-lived when production churn is high. If the test itself rewrites most partitions, price substantial additional storage even if cloning is still the easiest way to start it.
Query and DML execution still use compute. Give the experiment an execution project and a workload limit, chosen as carefully as its storage lifetime.
Review the destination’s readers before creating it
For a new clone, table access follows the destination dataset’s policies, and BigQuery copies row-level and column-level policies from the source. An ordinary source table without row or column restrictions can become readable by a wider group when placed in a broadly shared scratch dataset.
Use a restricted development dataset whose readers are allowed to receive the cloned data. Review the privileges of the developer who will mutate it, including the ability to change its access controls. Keep users who should see only filtered rows separate from users allowed to write table contents.
Copied row policies aren’t synchronized with the source. A later change to the source’s row policies, or the removal of source records, doesn’t update an existing experimental copy.
Record the clone wherever you track copies of the source’s data.
Verify access as the intended developer and as an identity that should be denied, including restricted rows and columns where they exist. Querying as the creation identity doesn’t test what other destination readers can see.
Create a fresh, expiring object and inspect it
This example assumes both datasets already exist in EU, belong to the same organization, and are approved for this data. The source is an eligible native table without row-level policies requiring additional maintenance permissions. Submit the job in EU through the development execution project.
CREATE TABLE `analytics-dev.scratch.orders_change_742`
CLONE `analytics-prod.core.orders`
OPTIONS (
expiration_timestamp = TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL 3 DAY),
description = 'Temporary clone for change 742; owner data-team',
labels = [('purpose', 'development'), ('change_id', '742')]
);The clone statement accepts those options. Setting an expiration needs the additional bigquery.tables.delete permission. Review source read permissions, destination creation permissions, and job submission separately. Scope destination write privileges to development, because a later statement can still write to production if the execution identity has that permission.
Use a fresh name and let an existing destination fail.
IF NOT EXISTS can leave a stale experimental table in place without an error. Reusing that table would make a later result look as though it came from a new clone when the creation statement did nothing.
Read the resulting table metadata: table_type should be CLONE, the base-table fields should identify the intended source, and snapshot_time_ms should identify the intended source point. Also check expiration, schema, and partitioning. Copy interfaces can produce a full copy when locations differ, so a command that says “clone” may not have shared any storage.
Keep these details with the change being tested, together with the test result and any derived tables.
Name the clone in the experimental SQL. Review compiled or generated destinations before running it, especially when a model graph contains more than one output.
Observe billed divergence and end the experiment
Don’t sum clone sizes from TABLE_STORAGE to calculate their extra storage cost. Its byte columns describe full-equivalent tables and overstate the incremental amount. Use them to understand data shape, allowing for the documented metadata delay, but not to allocate the clone bill.
The TABLE_STORAGE_USAGE_TIMELINE view includes billable clone deltas in daily MiB-seconds. It’s in Preview. It has about 72 hours of reporting delay and omits clones with no billable bytes. A missing row for today’s clone can mean no billable bytes or a row that hasn’t been reported yet. The delay also makes it unsuitable as an immediate spending stop for a short experiment.
Review the reported usage after it arrives, alongside source maintenance during the same period. That comparison helps set the lifetime of the next experiment. If the development budget unexpectedly owns old source storage, check source rewrites and older clones before blaming writes in the experiment.
Keep the code change and the evidence. Delete experimental and derived tables you no longer need, or verify that their configured expiration will remove them.
Expiration can be changed later and won’t cap the budget. An expired table also isn’t necessarily erased at that moment. If someone needs the data beyond the original deadline, give that copy a new purpose and its own lifetime.
More in this domain: Data
Browse allWhen cold history should stay in BigQuery
Keep cold history in BigQuery when retrieval costs would outweigh the storage savings.
BigQuery global queries or a local serving copy?
A global BigQuery query can suit occasional selective reads. An approved local copy can save transfers when reports repeatedly read the same remote data.
When external Parquet deserves a native BigQuery copy
Keep Parquet external for occasional reads. A native BigQuery copy can pay off when reports repeatedly scan the same files.
Publish a BigQuery dataset without sponsoring every reader's queries
Publish a BigQuery dataset when readers need SQL and have their own execution project. Offer versioned downloads for readers who just need the data.
When selective lookups can stay in BigQuery
Try a BigQuery search index for occasional, selective lookups on data already in the warehouse.
Related patterns
BigQuery physical vs. logical storage: compare the full bill
Physical billing rewards compression, but retained versions can consume the savings. Compare both models using the dataset's current data, rewrite history, and recovery requirements.
BigQuery tenant access starts with the query identity
Choose tenant isolation from the identity BigQuery sees on the report's query.
On-demand vs slots: the SME decision boundary
Start an SME warehouse on BigQuery on-demand pricing. Consider reservations when recurring workloads need predictable capacity or interfere with one another.
Publish related BigQuery tables as one consistent release
Publish related BigQuery tables in one DML transaction when the change fits. Use immutable releases when readers need consistency across separate queries.