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 ConnectorSource and target tables schema
To effectively load the BigQuery dataset into ClickHouse, the pipeline performs a column inference process with the following phases:- The templates build a schema object based on the target ClickHouse table.
- The templates iterate over the BigQuery dataset, and attempts to match columns based on their names.
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.
- Google Cloud Console
- Google Cloud CLI
Sign in to your Google Cloud Console and search for DataFlow.
- Press the
CREATE JOB FROM TEMPLATEbutton - Once the template form is open, enter a job name and select the desired region.
- In the
DataFlow Templateinput, typeClickHouseorBigQuery, and select theBigQuery to ClickHousetemplate - 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 server JDBC url, with the following format
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.- 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:GoogleCloudPlatform/DataflowTemplates— the upstream Google Cloud Platform repository.ClickHouse/DataflowTemplates— ClickHouse’s fork.