# CData Sync: History Mode (including Apache Kafka)

**URL:** <https://community.cdata.com/t/cdata-sync-history-mode-including-apache-kafka/366>\
**Category:** Getting started\
**Tags:** article\
**Created:** [August 29, 2023, 8:56pm UTC](https://community.cdata.com/t/cdata-sync-history-mode-including-apache-kafka/366 "2023-08-29T20:56:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerodj-cdata](https://sea3.discourse-cdn.com/cdata/user_avatar/community.cdata.com/jerodj-cdata/32/7_2.png) [@jerodj-cdata](https://community.cdata.com/u/jerodj-cdata)\
**Post date:** [August 29, 2023, 8:56pm UTC](https://community.cdata.com/t/cdata-sync-history-mode-including-apache-kafka/366/1 "2023-08-29T20:56:54Z")

</div>

CData Sync history mode provides a method for analyzing historical data in your data sources. History mode is a slowly changing dimension that stores and manages relatively static data (current and historical) in a data warehouse. That data can change slowly (but unpredictably) over time.

In Apache Kafka, the schema is regularly evolving (and often by design as the organization’s data needs evolve). CData Sync history mode fits in line with this concept and allows you to easily manage changing schema from producers and reflect those changes easily for the consumers.

In CData, you can use history mode (via the **Enable History Mode** option) to track the change history for data rows (records) and see how your data changes over time. History mode is available for all connectors that support replication by incremental check columns.

CData supports a combined approach to analyzing historical data. That is, the **Enable History Mode** option offers both robust tracking for auditing as well as time-series analysis.

History mode works on a per-table basis. So, you can decide which tables you want to analyze and then activate the option for those tables only.

In standard mode, Sync merges and updates existing rows whereas in history mode, Sync appends updated rows to the database table.

When you activate history mode:

- Sync maintains a full history of data changes for each data record in the source database table.
- Sync records those change versions to the corresponding table in your destination database table.

To enable this functionality, Sync includes three new columns in the destination table. These columns are defined in the following table:

| **Column Name** | **Column Type** | **Description** |
| --- | --- | --- |
| \_cdatasync\_active | Boolean | Specifies whether a record is active. |
| \_cdatasync\_start | Datetime | Specifies the datetime value of the incremental check column at the time the data record becomes active. This value indicates when the record was created or modified in the source table, based on a timestamp that increments with each data update. |
| \_cdatasync\_end | Datetime | Specifies the datetime value of the incremental check column at the time the data record becomes inactive. A null value in this column indicates that the record is active. |
| \_cdatasync\_operation | Varchar | Specifies the operation to use: Insert (I), Update (U), or Delete (D). **Note:** This column applies only when you use Change Data Capture (CDC). |
| \_cdatasync\_version | Varchar(100) | Specifies the version for each change in the format that is saved in the CSRS table. **Note:** This column applies only when you use CDC. |

## &nbsp;

## Restrictions and limitations&nbsp;

With history mode, the following restrictions apply:

- The source table must support an incremental check column.
- The source table must contain a primary key.
- The incremental check column must be a timestamp (datetime) column.
- The incremental check column cannot be a pseudocolumn because pseudocolumns do not have a value in the response and are used as criteria only.
- The destination table cannot exist. (Use the **Drop Table** option on the **Advanced** tab to re-create the table with history mode active.)

In addition, support for history mode is limited to the following destinations:

- Apache Kafka
- SQL Server
- MySQL
- PostgreSQL
- Oracle DB
- Snowflake
- Databricks
- Redshift

**Note:** Additional destinations will be added in the future.

## History mode activation for a job&nbsp;

To activate history mode for a job in Sync:

1. Navigate to the **Jobs** tab.

2. Click the job that contains the tables from which you want to select.

3. Scroll to **Job Settings** and click **Add Tables**. In the Add Tables modal that opens, select your tables.

4. Click **Add Selected Tables** to add the selected tables and to return to the **Job Settings** page.

5. Click the **Advanced** tab to open the advanced settings.

6. Scroll to **Replicate Options** and select **Enable History Mode**.

7. Click **Save Changes** (not shown) in the upper right of the **Job Settings** page to save and activate history mode for your selected tables.

## History mode activation for a task within a job&nbsp;

You can enable history mode for tasks, as well, from the **Advanced** tab in the task settings, as shown below:

 ![Task Settings Advanced History Mode Options](https://us1.discourse-cdn.com/cdata/original/2X/6/6d3f17eb452e41975c93fcfbf1220f29367c2c0c.png)

In the advanced settings for a task, history mode has three options:

- **Inherited From Job** : If this option is specified, the task inherits history mode from the job.
- **True** : This option enables history mode for the task.
- **False** This option disables history mode for the task.

History mode is disabled in the task settings also if a table does not support incremental check columns.

## Effects of changing the source table&nbsp;

When you change the source table by inserting, updating, or deleting rows, the destination is affected in various ways, as described in the following table:

| **Source Change** &nbsp; | **Destination Effect** &nbsp; |
| Inserted Row&nbsp; | A row is added to the destination table. \_cdatasync\_active is set to `True`, and \_cdatasync\_start is set to the incremental check-column value.&nbsp; |
| Updated Row&nbsp; | 
-   
The current row in the destination table is updated. \_cdatasync\_active is set to `False`, and \_cdatasync\_end is set to the incremental check-column value.&nbsp;
- A new row is inserted into the destination table. \_cdatasync\_active is set to `True`, and \_cdatasync\_start is set to the incremental check-column value.&nbsp;

 |
| Deleted Row&nbsp; | The current row in the destination table is updated. \_cdatasync\_active is set to `False`.&nbsp; |

## 

Free trial & more information

Visit our [CData Sync page](https://www.cdata.com/sync) to read more information about CData Sync. To try out history mode, [download a free 30-day trial](https://www.cdata.com/sync/download/)! As always, our world-class [Support Team](https://www.cdata.com/support/submit.aspx) is ready to answer any questions you may have.
