BigQuery
Enable BigQuery partitioning
Partition your BigQuery destination tables so each Artie merge reads only the partitions its rows fall in.
How you enable partitioning depends on whether the table already exists in BigQuery:
- New tables: Artie creates the table partitioned by hour, day, month or year from the column and granularity you select.
- Existing tables: BigQuery can’t partition a table after it’s created, so you recreate the table, then update its settings in Artie.
The examples in this guide use this source table in PostgreSQL:
CREATE TABLE events (
event_id SERIAL PRIMARY KEY,
event_name VARCHAR(255) NOT NULL,
description TEXT,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
);Choose a partition column
Pick a TIMESTAMP, DATETIME or DATE column that your queries filter on, such as created_at or event_date.
Pick a column whose value stays fixed after a row is inserted. Artie filters each merge to the partitions of the incoming rows’ values. A row whose value moves to a different partition doesn’t match its old copy, so the merge inserts a duplicate. For that reason, avoid a column like updated_at.
If any row in a batch has no value in the partition column, Artie merges that batch without the partition filter.
Choose a partition granularity
Pick how much time each partition covers. Artie defaults to Daily.
| Granularity | Use it when | Column types |
|---|---|---|
| Hourly | High-volume tables that only keep a few months of data | TIMESTAMP, DATETIME |
| Daily | Most change data capture (CDC) workloads | TIMESTAMP, DATETIME, DATE |
| Monthly | Tables with many years of history, or low volume per day | TIMESTAMP, DATETIME, DATE |
| Yearly | Very long history with low volume per month | TIMESTAMP, DATETIME, DATE |
BigQuery limits a single job to modifying 4,000 partitions, and a table to 10,000 partitions. A backfill merge can touch rows from across the whole table. Pick a granularity where your partition column spans fewer than 4,000 partitions: about 5 months of hours, or about 10 years of days.
Partition a new table
Artie adds partitioning only when it creates the table, so set the partition column before the table exists in BigQuery.
In a new pipeline
The setup flow asks for tables before the destination. Merge predicate appears in a table’s settings only after the pipeline has a BigQuery destination.
Connect BigQuery
In the pipeline setup flow, complete the Destination steps with BigQuery as the destination.
Open the table's settings
In the list of setup steps, select Choose tables, then select the
eventsrow.The table’s columns and settings open. If Replicate this table is off, turn it on.
Select the partition column
Expand Advanced options, then select
created_atin Merge predicate.Partition granularity appears, set to Daily.
Select the granularity
Select a Partition granularity, then select Done.
Hourly isn’t listed for a
DATEcolumn.Deploy
On Review and deploy, select Validate and deploy, then select Deploy.
When Artie creates the
eventstable, it adds the partitioning clause.Verify
Follow Verify partitioning once the table has data.
In a deployed pipeline
To partition a table that you add to a deployed pipeline, edit the pipeline before Artie creates the table.
Open the table's advanced settings
On the pipeline page, select Edit pipeline, then the Tables tab. On the
eventsrow, select Advanced settings.Advanced settings appears only on a replicated row. If the
eventsrow isn’t replicated, turn on replication for it first.Select the partition column
Under Optimizations, turn on Use a merge predicate, then select
created_atin Column name.Partition granularity appears, set to Daily.
Select the granularity
Select a Partition granularity, then select Close.
Hourly isn’t listed for a
DATEcolumn.Deploy
Select Save changes, then Deploy. In Validate and deploy, select Deploy.
When Artie creates the
eventstable, it adds the partitioning clause.Verify
Follow Verify partitioning once the table has data.
See Use a merge predicate for more on this table setting.
Partitioning clauses
Artie adds one of these clauses when it creates a table partitioned on a BigQuery TIMESTAMP column, like created_at in the example:
| Granularity | Partitioning clause |
|---|---|
| Hourly | PARTITION BY TIMESTAMP_TRUNC(created_at, HOUR) |
| Daily | PARTITION BY DATE(created_at) |
| Monthly | PARTITION BY TIMESTAMP_TRUNC(created_at, MONTH) |
| Yearly | PARTITION BY TIMESTAMP_TRUNC(created_at, YEAR) |
A DATETIME column uses DATETIME_TRUNC in place of TIMESTAMP_TRUNC. A PostgreSQL TIMESTAMP column without a time zone arrives in BigQuery as DATETIME, unless Force UTC timezone is on in the destination’s advanced settings. A DATE column is partitioned on the column itself for daily partitions, and uses DATE_TRUNC for monthly and yearly partitions.
Artie also filters each merge on the partition column, so BigQuery prunes partitions during merges.
Errors and limits
If Artie can’t partition the table, it stops with one of these errors instead of creating an unpartitioned table:
| Error | Cause |
|---|---|
partition column "created_at" must be a date or timestamp to partition the table, got: "string" | The column has another type, or it’s hashed or encrypted, which makes it a string. |
partition column "created_at" is a date, so the table cannot be partitioned by hour | Hourly is set on a DATE column. |
partition column "created_at" is not one of the columns of the table being created, or its type is not known yet | The column isn’t in the table Artie is creating, or Artie doesn’t know its type yet. |
These limits also apply:
- Time partitions only. For integer range partitioning, create the partitioned table in BigQuery first, then select the integer column as the merge predicate.
- No granularity for integers. Partition granularity appears only for a date or timestamp column.
- Fixed after creation. Changing the granularity doesn’t change an existing table. To switch, recreate the table.
- 4,000 partitions per job. If your partition column spans more, pick a coarser granularity.
Partition an existing table
If the table exists in BigQuery and isn’t partitioned, recreate it as a partitioned table while your pipeline is paused.
You need permission to run DDL statements (CREATE TABLE, DROP TABLE, ALTER TABLE) in your BigQuery dataset.
Pause delivery
On the pipeline page, select Pause pipeline…, keep Pause delivery only selected, then select Pause delivery.
Artie stops writing to BigQuery and keeps capturing source changes for up to 14 days. Nothing is merged while you restructure the table.
Create a partitioned copy in BigQuery
In the BigQuery console, run this statement to create a partitioned copy of the table:
SQLCREATE TABLE artie.events_copy PARTITION BY DATE(created_at) AS SELECT * FROM artie.events;For another granularity, swap in its partitioning clause, for example
PARTITION BY TIMESTAMP_TRUNC(created_at, MONTH).Replace the original table
After you verify the data in
events_copy, drop the original table:SQLDROP TABLE artie.events;Then rename the copy:
SQLALTER TABLE artie.events_copy RENAME TO events;Update the table's settings in Artie
On the pipeline page, select Edit pipeline, then the Tables tab. On the
eventsrow, select Advanced settings.Under Optimizations, turn on Use a merge predicate and select
created_atin Column name. Set Partition granularity to match how you partitioned the table, then select Close.Artie then filters each merge on the partition column, so BigQuery prunes partitions during merges. See Use a merge predicate for more on this table setting.
Deploy and resume
Select Save changes, then Deploy. In Validate and deploy, leave Resume pipeline after deployment on, then select Deploy.
The pipeline resumes and applies the held changes. Then follow Verify partitioning.
Verify partitioning
To confirm partitioning is active, run this query in BigQuery:
SELECT table_name, partition_id, total_rows
FROM `artie.INFORMATION_SCHEMA.PARTITIONS`
WHERE table_name = 'events'
ORDER BY partition_id;The query returns one row per partition. A single row with a NULL partition_id means the table isn’t partitioned.
Partitioned tables
A partitioned table is divided into segments called partitions, based on the value of a partition column. A query or merge that filters on that column reads fewer bytes.
Why use table partitions
Partitioning a table that Artie merges into has three effects:
- Faster merges: Artie’s merges scan only the relevant partitions instead of the entire table.
- Lower costs: Fewer bytes scanned lowers BigQuery compute charges under on-demand pricing.
- Partition-level management: Write to, delete or expire individual partitions without affecting the rest of the table.
Partitioning strategies
BigQuery has three ways to partition a table:
| Partitioning type | Description | Artie recommendation |
|---|---|---|
| Time partitioning | Partitions based on a TIMESTAMP, DATE, or DATETIME column. Supports hourly, daily, monthly, and yearly granularity. | Recommended. Works well with CDC workloads where data naturally has a time dimension. Artie creates these tables for you. |
| Integer range | Partitions based on value ranges of an integer column (e.g. customer_id 0–9 in one partition, 10–19 in the next). | Useful when your data has no natural time column but has a well-distributed integer key. Create the table in BigQuery yourself. |
| Ingestion time | Partitions based on when rows were inserted into BigQuery. | Not recommended. Artie filters merges only on a column from your source table, and the ingestion time isn’t one, so merges can’t prune partitions. |
Next steps
- BigQuery destination setup: configure BigQuery as a destination in Artie, including query priority settings.
- Capacity pricing: understand BigQuery’s pricing models and avoid unexpected costs.
Was this page helpful?
- Need help? Message us on Slack or email [email protected].
- Want a walkthrough? Book a demo.
- LLM? Read llms.txt.