Drop¶
ここでは、Confluent SMT io.confluent.connect.transforms.Drop
の使用方法を説明します。
説明¶
メッセージのキーまたは値に null を設定します。対応するスキーマを、同様に null に設定すること、省略可能に設定すること、既に省略可能になっているかを確認すること、または、そのままの状態を維持することができます。レコードキー用( io.confluent.connect.transforms.Drop$Key
)または値用(io.confluent.connect.transforms.Drop$Value
)の固有の変換タイプを使用します。
インストール¶
この変換は Confluent が開発したものであり、Kafka または Confluent Platform にデフォルトで同梱されるものではありません。この変換は、Confluent Hub クライアント を使用してインストールできます。
confluent-hub install confluentinc/connect-transforms:latest
例¶
以下の構成スニペットは、Drop
SMT の使用方法と構成方法を示しています。
スキーマのデフォルトの動作を使用してメッセージからキーをドロップします。これにより、キーがまだ null でない場合にキーが null 化されます。
"transforms": "dropKeyExample", "dropValueAndForceOptionalSchemaExample",
"transforms.dropKeyExample.type": "io.confluent.connect.transforms.Drop$Key"
メッセージから値をドロップします。値のスキーマが省略可能になっていない場合は、スキーマが強制的に上書きされ、省略可能になります。
"transforms.dropValueAndForceOptionalSchemaExample.type": "io.confluent.connect.transforms.Drop$Value",
"transforms.dropValueAndForceOptionalSchemaExample.schema.behavior": "force_optional"
レコードのコンテンツに Drop$Key
を使用し、schema.behavior
に nullify
を設定する場合:
"transforms.dropValueAndForceOptionalSchemaExample.type": "io.confluent.connect.transforms.Drop$Key",
"transforms.dropValueAndForceOptionalSchemaExample.schema.behavior": "nullify"
- 変換前 :
key: 24
、schema: {"type": "integer"}
- 変換後 :
key: null
、schema: null
キーが null 化され、スキーマが null 化されています。
レコードのコンテンツに Drop$Key
を使用し、schema.behavior
に retain
を設定する場合:
"transforms.dropValueAndForceOptionalSchemaExample.type": "io.confluent.connect.transforms.Drop$Key",
"transforms.dropValueAndForceOptionalSchemaExample.schema.behavior": "retain"
- 変換前 :
key: 24
、schema: {"type": "integer"}
- 変換後 :
key: null
、schema: {"type": "integer"}
キーは null 化され、スキーマは変更されていません。
レコードのコンテンツに Drop$Key
を使用し、schema.behavior
に validate
を設定する場合(スキーマは省略不可):
"transforms.dropValueAndForceOptionalSchemaExample.type": "io.confluent.connect.transforms.Drop$Key",
"transforms.dropValueAndForceOptionalSchemaExample.schema.behavior": "validate"
- 変換前 :
key: 24
、schema: {"type": "integer"}
- 変換後: スキーマが省略不可であるため、例外がスローされます。
レコードのコンテンツに Drop$Key
を使用し、schema.behavior
に validate
を設定する場合(スキーマは省略可能):
"transforms.dropValueAndForceOptionalSchemaExample.type": "io.confluent.connect.transforms.Drop$Key",
"transforms.dropValueAndForceOptionalSchemaExample.schema.behavior": "validate"
- 変換前 :
key: 24
、schema: {"type": "integer", "optional": true}
- 変換後 :
key: null
、schema: {"type": "integer", "optional": true}
キーは null 化され、スキーマは変更されていません。
レコードのコンテンツに Drop$Key
を使用し、schema.behavior
に force_optional
を設定する場合(スキーマは省略不可):
"transforms.dropValueAndForceOptionalSchemaExample.type": "io.confluent.connect.transforms.Drop$Key",
"transforms.dropValueAndForceOptionalSchemaExample.schema.behavior": "force_optional"
- 変換前 :
key: 24
、schema: {"type": "integer"}
- 変換後 :
key: null
、schema: {"type": "integer", "optional": "true"}
キーが null 化され、スキーマが省略可能になります。
レコードのコンテンツに Drop$Key
を使用し、schema.behavior
に force_optional
を設定する場合(スキーマは既に省略可能):
"transforms.dropValueAndForceOptionalSchemaExample.type": "io.confluent.connect.transforms.Drop$Key",
"transforms.dropValueAndForceOptionalSchemaExample.schema.behavior": "force_optional"
- 変換前 :
key: 24
、schema: {"type": "integer", "optional": true}
- 変換後 :
key: null
、schema: {"type": "integer", "optional": true}
キーは null 化され、スキーマは変更されていません。
ちなみに
その他の例については、マネージド型コネクターの Drop を参照してください。
特徴¶
Name | 説明 | 型 | デフォルト | 指定可能な値 | 重要度 |
---|---|---|---|---|---|
schema.behavior |
null でないスキーマの処理方法。nullify を設定すると、新しいレコードのスキーマが null になります。retain を設定すると、省略可能かどうかにかかわらず、スキーマが使用されます。validate を設定すると、まずスキーマがチェックされ、省略可能な場合はそのまま使用され、省略不可の場合は例外がスローされます。force_optional を設定すると、スキーマが省略可能になっていない場合は、上書きされ、省略可能になります。 |
string | nullify | [nullify、retain、validate、force_optional] | 中 |
述語¶
"述語" を使用することにより、一定の条件を満たすレコードのみに変換が適用されるように、変換を構成することができます。述語は変換チェーンで使用することができ、Filter(Apache Kafka) と組み合わせると、条件に基づいて特定のレコードを除外できます。詳細と例については、「述語」を参照してください。