CREATE EXTERNAL TABLE
Create an external table to connect to ClickHouse:Basic Example
Configuration Options
Required Settings
| Setting | Type | Description |
|---|---|---|
type | String | Must be ‘clickhouse’ |
address | String | ClickHouse host and native port (format: host:port) |
table | String | Target table name in ClickHouse |
Authentication Settings
| Setting | Type | Description | Default |
|---|---|---|---|
user | String | ClickHouse username | (empty) |
password | String | ClickHouse password | (empty) |
database | String | ClickHouse database name | default |
Connection Settings
| Setting | Type | Description | Default |
|---|---|---|---|
secure | Bool | Use TLS/SSL for connection | false |
compression | Bool | Enable compression | false |
pooled_connections | Int | Connection pool size | 16 |
ssl_verify_mode | String | SSL verification mode | (system default) |
ssl_ca_cert_file | String | Path to CA certificate | (empty) |
ssl_cert_file | String | Path to client certificate | (empty) |
ssl_key_file | String | Path to client private key | (empty) |
Reading from ClickHouse
When you query an external table, Proton reads data from ClickHouse and processes it locally.Simple Query
Query with Filtering
Aggregation Example
Writing to ClickHouse
INSERT Statement
Stream to ClickHouse with Materialized View
A common pattern is to continuously write streaming data to ClickHouse:Complete ETL Example
Read from Kafka, transform, and write to ClickHouse:ClickHouse Table Setup
Prepare your ClickHouse table before creating the external table in Proton:Secure Connection Example
Connect to ClickHouse Cloud or other TLS-enabled instances:Aiven for ClickHouse Example
Schema Inference
If you don’t specify columns when creating the external table, Proton automatically fetches the schema from ClickHouse:Default Values
When inserting data, columns not specified in the INSERT or materialized view will use ClickHouse’s default values:Multiple ClickHouse Targets
You can write to multiple ClickHouse instances:Performance Considerations
Connection Pooling
Adjustpooled_connections based on concurrency:
Compression
Enable compression for network efficiency:Batch Writes
Proton automatically batches writes to ClickHouse. The batch size is controlled by Proton’s internal settings.Error Handling
Connection Failures
If ClickHouse is unavailable during external table creation:- With
attach=false(CREATE): Connection is validated, creation fails - With
attach=true(ATTACH): Validation is skipped
Write Failures
If writes fail, the materialized view will retry or stop depending on error type. Check Proton logs for details.Limitations
- No predicate pushdown: Filters are executed in Proton after fetching data
- Full table scans: Reading always fetches the entire result set matching the SELECT
- No distributed tables: Connect to a specific ClickHouse node
- Native protocol only: Uses ClickHouse native protocol (default port 9000/9440)
Best Practices
- Use materialized views for continuous writes: More efficient than individual INSERTs
- Enable secure connections in production: Use
secure=truewith proper certificates - Match data types: Ensure Proton and ClickHouse column types are compatible
- Optimize ClickHouse tables: Use appropriate ENGINE, PARTITION, and ORDER BY
- Monitor connection pool: Adjust
pooled_connectionsfor workload