Skip to main content
The BigQuery to ClickHouse template is a batch pipeline that ingests data from a BigQuery table into a ClickHouse table. The template can read the entire table or filter specific records using a provided SQL query.

Pipeline requirements

  • The source BigQuery table must exist.
  • The target ClickHouse table must exist.
  • The ClickHouse host must be accessible from the Dataflow worker machines.

Template parameters



Default values for all ClickHouseIO parameters can be found in ClickHouseIO Apache Beam Connector

Source and target tables schema

To effectively load the BigQuery dataset into ClickHouse, the pipeline performs a column inference process with the following phases:
  1. The templates build a schema object based on the target ClickHouse table.
  2. The templates iterate over the BigQuery dataset, and attempts to match columns based on their names.

Having said that, your BigQuery dataset (either table or query) must have the exact same column names as your ClickHouse target table.

Data type mapping

The BigQuery types are converted based on your ClickHouse table definition. Therefore, the above table lists the recommended mapping you should have in your target ClickHouse table (for a given BigQuery table/query):

Running the Template

The BigQuery to ClickHouse template is available for execution via the Google Cloud CLI.
Be sure to review this document, and specifically the above sections, to fully understand the template’s configuration requirements and prerequisites.
Sign in to your Google Cloud Console and search for DataFlow.
  1. Press the CREATE JOB FROM TEMPLATE button
  2. Once the template form is open, enter a job name and select the desired region.
  3. In the DataFlow Template input, type ClickHouse or BigQuery, and select the BigQuery to ClickHouse template
  4. Once selected, the form will expand to allow you to provide additional details:
    • The ClickHouse server JDBC url, with the following format jdbc:clickhouse://host:port/schema.
    • The ClickHouse username.
    • The ClickHouse target table name.

The ClickHouse password option is marked as optional, for use cases where there is no password configured. To add it, please scroll down to the Password for ClickHouse Endpoint option.
  1. Customize and add any BigQuery/ClickHouseIO related configurations, as detailed in the Template Parameters section

Monitor the job

Navigate to the Dataflow Jobs tab in your Google Cloud Console to monitor the status of the job. You’ll find the job details, including progress and any errors:

Troubleshooting

Memory limit (total) exceeded error (code 241)

This error occurs when ClickHouse runs out of memory while processing large batches of data. To resolve this issue:
  • Increase the instance resources: Upgrade your ClickHouse server to a larger instance with more memory to handle the data processing load.
  • Decrease the batch size: Adjust the batch size in your Dataflow job configuration to send smaller chunks of data to ClickHouse, reducing memory consumption per batch. These changes can help balance resource usage during data ingestion.

Template source code

The template’s source code is available in:
Last modified on July 3, 2026