Skip to main content

Description

Apache Avro is a row-oriented serialization format that uses binary encoding for efficient data processing. The AvroConfluent format supports reading and writing Avro-encoded messages using the Confluent Schema Registry (or API-compatible services). Each message uses the Confluent wire format: a magic byte (0x00) followed by a 4-byte big-endian schema ID, followed by the Avro binary datum. When reading, ClickHouse resolves the schema ID by querying the registry. When writing, ClickHouse registers the schema derived from the output columns and prepends the resulting ID to each row. Schemas are cached for optimal performance.

Data type mapping

The table below shows all data types supported by the Apache Avro format, and their corresponding ClickHouse data types in INSERT and SELECT queries. * bytes is default, controlled by setting output_format_avro_string_column_pattern ** The Variant type implicitly accepts null as a field value, so for example the Avro union(T1, T2, null) will be converted to Variant(T1, T2). As a result, when producing Avro from ClickHouse, we have to always include the null type to the Avro union type set as we don’t know if any value is actually null during the schema inference. *** Avro logical types Unsupported Avro logical data types:
  • time-millis
  • time-micros
  • duration

Format settings

Examples

Reading from Kafka

To read an Avro-encoded Kafka topic using the Kafka table engine, use the format_avro_schema_registry_url setting to provide the URL of the schema registry.

Writing to Kafka

To write AvroConfluent messages to a Kafka topic, set both the schema registry URL and the subject name. The schema is automatically registered with the registry on the first write.

Using basic authentication

If your schema registry requires basic authentication (e.g., if you’re using Confluent Cloud), you can provide URL-encoded credentials in the format_avro_schema_registry_url setting.

Troubleshooting

To monitor ingestion progress and debug errors with the Kafka consumer, you can query the system.kafka_consumers system table. If your deployment has multiple replicas (e.g., ClickHouse Cloud), you must use the clusterAllReplicas table function.
If you run into schema resolution issues, you can use kafkacat with clickhouse-local to troubleshoot:
Last modified on July 2, 2026