メインコンテンツまでスキップ
メインコンテンツまでスキップ

AvroConfluent

InputOutputAlias

説明

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データ型 INSERTClickHouseデータ型Avroデータ型 SELECT
boolean, int, long, float, doubleInt(8\16\32), UInt(8\16\32)int
boolean, int, long, float, doubleInt64, UInt64long
boolean, int, long, float, doubleFloat32float
boolean, int, long, float, doubleFloat64double
bytes, string, fixed, enumStringbytes または string *
bytes, string, fixedFixedString(N)fixed(N)
enumEnum(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, …) **
nullNullable(Nothing)null
int (date) ***Date, Date32int (date) ***
long (timestamp-millis) ***DateTime64(3)long (timestamp-millis) ***
long (timestamp-micros) ***DateTime64(6)long (timestamp-micros) ***
bytes (decimal) ***DateTime64(N)bytes (decimal) ***
intIPv4int
fixed(16)IPv6fixed(16)
bytes (decimal) ***Decimal(P, S)bytes (decimal) ***
string (uuid) ***UUIDstring (uuid) ***
fixed(16)Int128/UInt128fixed(16)
fixed(32)Int256/UInt256fixed(32)
recordTuplerecord

* 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

使用例

スキーマ解決を迅速に確認するために、kafkacatclickhouse-local と組み合わせて使用できます。

AvroConfluentKafka で使用するには:

フォーマット設定

スキーマレジストリ URL は format_avro_schema_registry_url で設定されます。

注記

format_avro_schema_registry_url の設定は、再起動後にその値を維持するために users.xml に設定する必要があります。また、 Kafka テーブルエンジンの format_avro_schema_registry_url 設定を使用することもできます。

設定説明デフォルト
input_format_avro_allow_missing_fieldsAvro/AvroConfluent フォーマットの場合: スキーマにフィールドが見つからない場合はエラーの代わりにデフォルト値を使用する0
input_format_avro_null_as_defaultAvro/AvroConfluent フォーマットの場合: null および非 Nullable カラムの場合にデフォルトを挿入する0
format_avro_schema_registry_urlAvroConfluent フォーマットの場合: Confluent Schema Registry の URL。