AvroConfluent
Input | Output | Alias |
---|---|---|
✔ | ✗ |
説明
AvroConfluent は、Kafka および Confluent Schema Registry と一般的に使用される単一オブジェクトの Avro メッセージのデコードをサポートしています。
各 Avro メッセージはスキーマ ID を埋め込んでおり、スキーマレジストリの助けを借りて実際のスキーマに解決できます。
スキーマは、一度解決されるとキャッシュされます。
データ型のマッチング
The table below shows all data types supported by the Apache Avro format, and their corresponding ClickHouse data types in INSERT
and SELECT
queries.
Avroデータ型 INSERT | ClickHouseデータ型 | Avroデータ型 SELECT |
---|---|---|
boolean , int , long , float , double | Int(8\16\32), UInt(8\16\32) | int |
boolean , int , long , float , double | Int64, UInt64 | long |
boolean , int , long , float , double | Float32 | float |
boolean , int , long , float , double | Float64 | double |
bytes , string , fixed , enum | String | bytes または string * |
bytes , string , fixed | FixedString(N) | fixed(N) |
enum | Enum(8\16) | enum |
array(T) | Array(T) | array(T) |
map(V, K) | Map(V, K) | map(string, K) |
union(null, T) , union(T, null) | Nullable(T) | union(null, T) |
union(T1, T2, …) ** | Variant(T1, T2, …) | union(T1, T2, …) ** |
null | Nullable(Nothing) | null |
int (date) *** | Date, Date32 | int (date) *** |
long (timestamp-millis) *** | DateTime64(3) | long (timestamp-millis) *** |
long (timestamp-micros) *** | DateTime64(6) | long (timestamp-micros) *** |
bytes (decimal) *** | DateTime64(N) | bytes (decimal) *** |
int | IPv4 | int |
fixed(16) | IPv6 | fixed(16) |
bytes (decimal) *** | Decimal(P, S) | bytes (decimal) *** |
string (uuid) *** | UUID | string (uuid) *** |
fixed(16) | Int128/UInt128 | fixed(16) |
fixed(32) | Int256/UInt256 | fixed(32) |
record | Tuple | record |
* bytes
はデフォルトで、設定 output_format_avro_string_column_pattern
によって制御されます。
** Variantタイプ はフィールド値として null
を暗黙的に受け入れるため、たとえば Avro の union(T1, T2, null)
は Variant(T1, T2)
に変換されます。その結果、ClickHouseからAvroを生成する際には、スキーマ推論中に実際に値が null
であるかどうかわからないため、常に null
型をAvroの union
型セットに含める必要があります。
*** Avro論理型
サポートされていないAvro論理データ型:
time-millis
time-micros
duration
使用例
スキーマ解決を迅速に確認するために、kafkacat を clickhouse-local と組み合わせて使用できます。
AvroConfluent
を Kafka で使用するには:
フォーマット設定
スキーマレジストリ URL は format_avro_schema_registry_url
で設定されます。
format_avro_schema_registry_url
の設定は、再起動後にその値を維持するために users.xml
に設定する必要があります。また、 Kafka
テーブルエンジンの format_avro_schema_registry_url
設定を使用することもできます。
設定 | 説明 | デフォルト |
---|---|---|
input_format_avro_allow_missing_fields | Avro/AvroConfluent フォーマットの場合: スキーマにフィールドが見つからない場合はエラーの代わりにデフォルト値を使用する | 0 |
input_format_avro_null_as_default | Avro/AvroConfluent フォーマットの場合: null および非 Nullable カラムの場合にデフォルトを挿入する | 0 |
format_avro_schema_registry_url | AvroConfluent フォーマットの場合: Confluent Schema Registry の URL。 |