Data Mapping
On this page
Default Table Name
By default, the SingleStore Kafka Sink Connector ("the connector") writes records from each Kafka topic to a SingleStore table with the same name as the Kafka topic.orders
are written to the orders
table.
Write to a Custom Table
You can write records to a custom table using either of the following:
-
Specify the target table using the
singlestore.
property.tableName. <topicName> -
Use dynamic record routing to map fields to specific tables.
Using the singlestore. tableName. <topicName>
Property
To override the default behavior and explicitly specify the name of the target SingleStore table for a topic, use the singlestore.
configuration property.orders
topic are written to a table named cust_
.
singlestore.tableName.orders=cust_orders
Using Dynamic Record Routing
You can also configure dynamic routing of records to tables based on a field in the Kafka record.singlestore.
property to specify the field that determines the target table and use singlestore.
to map the field values to table names.
For example, consider the following configuration:
singlestore.recordToTable.mappingField=data.tableType
singlestore.recordToTable.mapping.sales=sales_data
singlestore.recordToTable.mapping.users=user_profiles
This configuration specifies that when a Kafka record contains a field data
(which is a struct), it is mapped as follows based on the value of the tableType
field:
-
If
data
contains a fieldtableType
with the valuesales
, the record is written to thesales_
table.data -
If
data
contains a fieldtableType
with the valueusers
, the record is written to theuser_
table.profiles
Record-to-Row Mapping
The connector maps each Kafka record to a row in the target SingleStore table according to the structure of the record's value as follows:
Record value is not a |
The record is written as a row with a single column.
|
Record value is a |
Each field in the record is mapped to a column with the same name in the target table. |
By default, all the fields are inserted into the table.field.
property and specify the fields to insert.fields.
to insert only the ID
, code
, and quantity
fields from the Kafka record, and ignore all the other fields.
You can also explicitly specify field-to-column mappings using the singlestore.
property, which allows you to map Kafka records fields, including nested fields, to specific columns in the target table.
singlestore.columnToField.customer_orders.customer_id=payload.user.id
singlestore.columnToField.customer_orders.order_total=payload.order.total
In this configuration, the payload.
field is mapped to the customer_
column and the payload.
field is mapped to the order_
column in the customer_
table.
Note
When either of the fields.
and singlestore.
properties are used, fields not included in the list or mapping are ignored.
Last modified: August 3, 2025