<Header icon={<img src="/docs/logos/bigquery.svg" className="w-9 h-9 inline" />}>BigQuery</Header>

BigQuery is a cloud-based SQL data warehouse service developed by Google.

## Features

| Feature                                       | Supported |
|-----------------------------------------------|-----------|
| [Batch Mode](#batch-mode)                     | ✅         |
| [Stream Mode](#stream-mode)                   | ❌         |
| [Deduplication](#deduplication)               | ✅         |
| [Queries Optimization](#queries-optimization) | ✅         |

## Configuration

<DestinationConfiguration type="bigquery" />


## Advanced: Implementation Details

This section describes how Jitsu implements various modes and features for BigQuery.

### Batch Mode

 - Jitsu collects events batches in tmp file on file system.
 - Using Loader API Jitsu loads data from tmp file into BigQuery tmp_table.
 - Using Copier API Jitsu copy data from tmp_table to target_table

### Stream Mode

:::danger[Not supported]

It's possible to implement stream mode for BigQuery, but data Deduplication cannot be supported in this mode.
So it is currently disabled in Jitsu.

:::


### Deduplication

Data deduplication in BigQuery is based on [MERGE statement](https://cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax#merge_statement).
Merge condition is based on primary key column configured on connection level.

<details>
<summary>Details</summary>

- Write to tmp file
- Deduplicate rows in  tmp file
- Use Loader API to load to tmp_table from tmp file
- `MERGE into target_table T using tmp_table TMP on T.pk_field=TMP.pk_field when matched then UPDATE ... when not matched them INSERT ...`

</details>

### Queries Optimization

**Timestamp** connection setting is used to optimize SELECT queries.

Jitsu creates [time-unit column-partitioned](https://cloud.google.com/bigquery/docs/partitioned-tables#date_timestamp_partitioned_tables) table with specified timestamp column and daily partitioning.