Integrating Google Cloud Storage with ClickHouse Cloud

[Edit this page](https://github.com/ClickHouse/clickhouse-docs/blob/main/docs/integrations/data-ingestion/clickpipes/object-storage/google-cloud-storage/01_overview.md)

The GCS ClickPipe provides a fully-managed and resilient way to ingest data from Google Cloud Storage (GCS). It supports both **one-time** and **continuous ingestion** with exactly-once semantics.

GCS ClickPipes can be deployed and managed manually using the ClickPipes UI, as well as programmatically using [OpenAPI](https://clickhouse.com/docs/cloud/manage/api/swagger#tag/ClickPipes/paths/~1v1~1organizations~1%7BorganizationId%7D~1services~1%7BserviceId%7D~1clickpipes/post) and [Terraform](https://registry.terraform.io/providers/ClickHouse/clickhouse/latest/docs/resources/clickpipe).

## Supported formats[​](#supported-formats "Direct link to Supported formats")

- [JSON](/docs/interfaces/formats/JSON)
- [CSV](/docs/interfaces/formats/CSV)
- [TSV](/docs/interfaces/formats/TabSeparated)
- [Parquet](/docs/interfaces/formats/Parquet)
- [Avro](/docs/interfaces/formats/Avro)

## Features[​](#features "Direct link to Features")

### One-time ingestion[​](#one-time-ingestion "Direct link to One-time ingestion")

By default, the GCS ClickPipe will load all files matched by a pattern from the specified bucket into the ClickHouse destination table in a single batch operation. Once the ingestion task completes, the ClickPipe stops automatically. This one-time ingestion mode provides exactly-once semantics, ensuring that each file is processed reliably without duplicates.

### Continuous ingestion[​](#continuous-ingestion "Direct link to Continuous ingestion")

When continuous ingestion is enabled, ClickPipes continuously ingests data from the specified path. To determine ingestion order, the GCS ClickPipe relies on the implicit [lexicographical order](#continuous-ingestion-lexicographical-order) of files, by default. It can also be configured to ingest files in [any order](#continuous-ingestion-any-order) using a [Google Cloud Pub/Sub](https://cloud.google.com/pubsub) subscription [configured to provide notifications for the bucket](https://docs.cloud.google.com/storage/docs/reporting-changes#command-line).

#### Lexicographical order[​](#continuous-ingestion-lexicographical-order "Direct link to Lexicographical order")

The GCS ClickPipe assumes files are added to a bucket in lexicographical order, and relies on this implicit order to ingest files sequentially. This means that any new file **must** be lexically greater than the last ingested file. For example, files named `file1`, `file2`, and `file3` will be ingested sequentially, but if a new `file 0` is added to the bucket, it will be **ignored** because the file name isn't lexically greater than the last ingested file.

In this mode, the GCS ClickPipe does an initial load of **all files** in the specified path, and then polls for new files at a configurable interval (by default, 30 seconds). It is **not possible** to start ingestion from a specific file or point in time — ClickPipes will always load all files in the specified path.

#### Any order[​](#continuous-ingestion-any-order "Direct link to Any order")

Tip

See [Configuring unordered mode for continuous ingestion](/docs/integrations/clickpipes/object-storage/gcs/unordered-mode) for step-by-step instructions.

It's possible to configure a GCS ClickPipe to ingest files that don't have an implicit order by setting up a [Google Cloud Pub/Sub](https://docs.cloud.google.com/storage/docs/pubsub-notifications) subscription that receives notifications from the bucket. This allows ClickPipes to listen for object created events and ingest any new files regardless of the file naming convention.

Note

Unordered mode is **not** supported for public buckets. It requires **Service Account** authentication and a [Google Cloud Pub/Sub](https://cloud.google.com/pubsub) subscription connected to the bucket.

In this mode, the GCS ClickPipe does an initial load of **all files** in the selected path, and then listens for `OBJECT_FINALIZE` notifications via the Pub/Sub subscription that match the specified path. Any message for a previously seen file, file not matching the path, or event of a different type will be **ignored**. It is **not possible** to start ingestion from a specific file or point in time — ClickPipes will always load all files in the selected path.

### File pattern matching[​](#file-pattern-matching "Direct link to File pattern matching")

Object Storage ClickPipes follow the POSIX standard for file pattern matching. All patterns are **case-sensitive** and match the **full path** after the bucket name. For better performance, use the most specific pattern possible (e.g., `data-2024-*.csv` instead of `*.csv`).

#### Supported patterns[​](#supported-patterns "Direct link to Supported patterns")

|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Pattern Description Example Matches|  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `?` Matches exactly **one** character (excluding `/`) `data-?.csv` `data-1.csv`, `data-a.csv`, `data-x.csv`| `*` Matches **zero or more** characters (excluding `/`) `data-*.csv` `data-1.csv`, `data-001.csv`, `data-report.csv`, `data-.csv`| `**`   Recursive Matches **zero or more** characters (including `/`). Enables recursive directory traversal. `logs/**/error.log` `logs/error.log`, `logs/2024/error.log`, `logs/2024/01/error.log` | | | | | | | | | | | | | | | |

**Examples:**

- `https://bucket.s3.amazonaws.com/folder/*.csv`
- `https://bucket.s3.amazonaws.com/logs/**/data.json`
- `https://bucket.s3.amazonaws.com/file-?.parquet`
- `https://bucket.s3.amazonaws.com/data-2024-*.csv.gz`

#### Unsupported patterns[​](#unsupported-patterns "Direct link to Unsupported patterns")

|  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Pattern Description Example Alternatives|  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | | `{abc,def}` Brace expansion - alternatives `{logs,data}/file.csv` Create separate ClickPipes for each path.|  |  |  |  | | --- | --- | --- | --- | | `{N..M}` Numeric range expansion `file-{1..100}.csv` Use `file-*.csv` or `file-?.csv`. | | | | | | | | | | | |

**Examples:**

- `https://bucket.s3.amazonaws.com/{documents-01,documents-02}.json`
- `https://bucket.s3.amazonaws.com/file-{1..100}.csv`
- `https://bucket.s3.amazonaws.com/{logs,metrics}/data.parquet`

### Exactly-once semantics[​](#exactly-once-semantics "Direct link to Exactly-once semantics")

Various types of failures can occur when ingesting large dataset, which can result in a partial inserts or duplicate data. Object Storage ClickPipes are resilient to insert failures and provides exactly-once semantics. This is accomplished by using temporary "staging" tables. Data is first inserted into the staging tables. If something goes wrong with this insert, the staging table can be truncated and the insert can be retried from a clean state. Only when an insert is completed and successful, the partitions in the staging table are moved to target table. To read more about this strategy, check-out [this blog post](https://clickhouse.com/blog/supercharge-your-clickhouse-data-loads-part3).

### Virtual columns[​](#virtual-columns "Direct link to Virtual columns")

To track which files have been ingested, include the `_file` virtual column to the column mapping list. The `_file` virtual column contains the filename of the source object, which can be used to query which files have been processed.

## Access control[​](#access-control "Direct link to Access control")

### Permissions[​](#permissions "Direct link to Permissions")

The GCS ClickPipe supports public and private buckets. [Requester Pays](https://docs.cloud.google.com/storage/docs/requester-pays) buckets are **not** supported.

#### GCS bucket[​](#gcs-bucket "Direct link to GCS bucket")

The service account used by ClickPipes must allow the following actions at the bucket level: