Mapping a Kafka Struct

Mapping a record with a key and Apache Kafka Struct value.

A Struct is an Apache Kafka Connect data object that is used to represent complex data structures. Process a Struct with either the JsonConverter or AvroConverter. Typically, Kafka Source Connectors use Struct when writing records to Kafka. Specify individual fields of the Struct in the connector mapping.
Tip: See the Apache Kafka javadocs for more information.

In this example, baseball_topic has a primitive string key and JSON Struct value. The DataStax Connector can process the individual fields of the Struct.

Sample Kafka Record
key value
               { "number":50,
                 "street":"4 yawkey way",
The DataStax keyspace name is baseball_keyspace and table name is baseball_table. Use the following command to create the table:
CREATE TABLE baseball_keyspace.baseball_table (team text primary key, number int,
          firstname text, lastname text, street text, city text);
Configure the connector settings and use the following to map the fields:
“team=key,number=value.number, firstname=value.firstname, lastname=value.lastname, street=value.street,”

See the DataStax Kafka Examples for more.