-
Notifications
You must be signed in to change notification settings - Fork 468
Add Avro -> Kafka Connect type mapping and unsupported avro schemas #6081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -138,27 +138,27 @@ Sink, use [Kafka Connect Transformations](https://docs.confluent.io/platform/cur | |
|
|
||
| **With a schema declared:** | ||
|
|
||
| | Kafka Connect Type | ClickHouse Type | Supported | Primitive | | ||
| | --------------------------------------- |-----------------------| --------- | --------- | | ||
| | STRING | String | ✅ | Yes | | ||
| | STRING | JSON. See below (1) | ✅ | Yes | | ||
| | INT8 | Int8 | ✅ | Yes | | ||
| | INT16 | Int16 | ✅ | Yes | | ||
| | INT32 | Int32 | ✅ | Yes | | ||
| | INT64 | Int64 | ✅ | Yes | | ||
| | FLOAT32 | Float32 | ✅ | Yes | | ||
| | FLOAT64 | Float64 | ✅ | Yes | | ||
| | BOOLEAN | Boolean | ✅ | Yes | | ||
| | ARRAY | Array(T) | ✅ | No | | ||
| | MAP | Map(Primitive, T) | ✅ | No | | ||
| | STRUCT | Variant(T1, T2, ...) | ✅ | No | | ||
| | STRUCT | Tuple(a T1, b T2, ...) | ✅ | No | | ||
| | STRUCT | Nested(a T1, b T2, ...) | ✅ | No | | ||
| | STRUCT | JSON. See below (1), (2) | ✅ | No | | ||
| | BYTES | String | ✅ | No | | ||
| | org.apache.kafka.connect.data.Time | Int64 / DateTime64 | ✅ | No | | ||
| | org.apache.kafka.connect.data.Timestamp | Int32 / Date32 | ✅ | No | | ||
| | org.apache.kafka.connect.data.Decimal | Decimal | ✅ | No | | ||
| | Kafka Connect Type | ClickHouse Type | Supported | Primitive | | ||
| |-----------------------------------------|--------------------------|-----------|-----------| | ||
| | STRING | String | ✅ | Yes | | ||
| | STRING | JSON. See below (1) | ✅ | Yes | | ||
| | INT8 | Int8 | ✅ | Yes | | ||
| | INT16 | Int16 | ✅ | Yes | | ||
| | INT32 | Int32 | ✅ | Yes | | ||
| | INT64 | Int64 | ✅ | Yes | | ||
| | FLOAT32 | Float32 | ✅ | Yes | | ||
| | FLOAT64 | Float64 | ✅ | Yes | | ||
| | BOOLEAN | Boolean | ✅ | Yes | | ||
| | ARRAY | Array(T) | ✅ | No | | ||
| | MAP | Map(Primitive, T) | ✅ | No | | ||
| | STRUCT | Variant(T1, T2, ...) | ✅ | No | | ||
| | STRUCT | Tuple(a T1, b T2, ...) | ✅ | No | | ||
| | STRUCT | Nested(a T1, b T2, ...) | ✅ | No | | ||
| | STRUCT | JSON. See below (1), (2) | ✅ | No | | ||
| | BYTES | String | ✅ | No | | ||
| | org.apache.kafka.connect.data.Time | Int64 / DateTime64 | ✅ | No | | ||
| | org.apache.kafka.connect.data.Timestamp | Int32 / Date32 | ✅ | No | | ||
| | org.apache.kafka.connect.data.Decimal | Decimal | ✅ | No | | ||
|
|
||
| - (1) - JSON is supported only when ClickHouse settings has `input_format_binary_read_json_as_string=1`. This works only for RowBinary format family and the setting affects all columns in the insert request so they all should be a string. Connector will convert STRUCT to a JSON string in this case. | ||
|
|
||
|
|
@@ -249,6 +249,74 @@ The connector can consume data from multiple topics | |
| } | ||
| ``` | ||
|
|
||
| ###### Avro type mapping {#avro-type-mapping} | ||
| The type mapping below is defined by `io.confluent.connect.avro.AvroConverter`, the official Avro serializer/deserializer implementation in Kafka Connect. See the Kafka Connect [docs](https://docs.confluent.io/platform/current/connect/userguide.html#avro) for advanced information on conversion logic. | ||
|
|
||
| ✅: Supported | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar as for protobuf docs
|
||
|
|
||
| ❌: Not supported | ||
|
|
||
| ️⚠️: Partially supported | ||
|
|
||
| | Avro Type | Kafka Connect Type | Supported | Notes | | ||
| |-----------|--------------------|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| | null | _N/A_ | ❌ | Not supported as a standalone type, but can be used in unions | | ||
| | boolean | BOOLEAN | ✅ | | | ||
| | int | INT8/INT16/INT32 | ✅ | Defaults to INT32. Resolves to INT8 if the schema has property `connect.type=int8` (analagously for INT16 if `connect.type=int16`) | | ||
| | long | INT64 | ✅ | | | ||
| | float | FLOAT32 | ✅ | | | ||
| | double | FLOAT64 | ✅ | | | ||
| | bytes | BYTES | ✅ | | | ||
| | string | STRING | ✅ | | | ||
| | record | STRUCT | ✅ | | | ||
| | enum | STRING | ✅ | | | ||
| | array | ARRAY/MAP | ✅ | Defaults to ARRAY. Resolves to MAP if the field was originally constructed via `AvroData.fromConnectSchema` ([source](https://github.com/confluentinc/schema-registry/blob/174907bfc0d9424e8d02e788f450f4afcdda1750/avro-data/src/main/java/io/confluent/connect/avro/AvroData.java#L943)) | | ||
| | map | MAP | ✅ | | | ||
| | union | STRUCT/`<T>` | ⚠️ | Defaults to STRUCT. Resolves to the singleton type `T` in the union definition if `flatten.singleton.unions=true` (see [docs](https://docs.confluent.io/cloud/current/connectors/reference/connector-configuration.html#value-converter-flatten-singleton-unions)) | | ||
| | fixed | BYTES | ⚠️ | Fixed `decimal` logical type is not supported (see below) | | ||
|
|
||
| Refer to [Supported data types](#supported-data-types) for the mapping between Kafka Connect types and ClickHouse types. | ||
|
|
||
| ###### Unsupported Avro schemas {#unsupported-avro-schemas} | ||
|
|
||
| The following Avro schemas are unsupported by the connector: | ||
| - fixed `decimal` logical type | ||
| ```json | ||
| {"name": "decimal_18_4", "type": "fixed", "size": 8, "logicalType": "decimal", "precision": 18, "scale": 4} | ||
| ``` | ||
| - nullable unions | ||
| ```json | ||
| {"name": "mixed_union", "type": ["null", "string", "int"], "default": null} | ||
| ``` | ||
| - record unions | ||
| ```json | ||
| { | ||
| "name": "record_union", | ||
| "type": [ | ||
| { | ||
| "type": "record", | ||
| "name": "TypeA", | ||
| "fields": [ | ||
| { | ||
| "name": "label", | ||
| "type": "string" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "type": "record", | ||
| "name": "TypeB", | ||
| "fields": [ | ||
| { | ||
| "name": "count", | ||
| "type": "int" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ##### Protobuf schema support {#protobuf-schema-support} | ||
|
|
||
| ```json | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed table formatting, no content changes