How to Define YAML for Incremental Data Updates in ETL Pipelines in Bold BI
Overview
Incremental data updates in Bold BI can be achieved by combining:
- Bold Data Hub pipelines (YAML configuration) for extracting only new or modified records.
- Bold BI Incremental Refresh for efficiently updating datasets used by dashboards and reports.
This article explains how to configure both components to support incremental data loading and prevent duplicate records during syncronization.
Prerequisites
Before configuring incremental loading, ensure the source table contains:
- A unique primary key column (for example, ticketid)
- A column that can identify newly added or modified records (for example, LastUpdatedOn)
Steps to Configure Incremental Updates
1. Create a Pipeline in Bold Data Hub
- Navigate to Bold Data Hub.
- Click Add Pipeline.
- Upload or configure the YAML connector file.
- Save the pipeline.
2. Configure Incremental Extraction in YAML
Add the following metadata configuration for the table:
tables:
- name: ozono
replication_method: INCREMENTAL
replication_key: LastUpdatedOn
replication_value: '2023-01-01 00:00:00'
primaryKeys:
- device_id
Configuration Details
| Setting | Description |
|---|---|
| replication_method: INCREMENTAL | Extracts only newly added records after each run. |
| replication_key | Date/time column used to identify new or modified records. |
| PrimaryKeys | Unique identifier(s) used to detect duplicate records. |
Note: Incremental extraction retrieves records that are new or have been modified since the last successful execution, based on the configured replication key.
3. Configure Target Load Behavior
To prevent duplicate records, configure the destination to use an appropriate load method.
load_method: upsert
Why Use Upsert?
- New records are inserted.
- Existing records with matching primary keys are updated.
- Duplicate records can be avoided when the destination supports upsert operations and the appropriate primary key is configured.
4. Explicitly Define Primary Keys to Avoid Inferred Constraints (Preventing Automatic Primary Key Inference)
-
In some scenarios, destination tables may be created with a composite primary key using multiple
NOT NULLcolumns. This can cause incremental load failures or constraint-related errors when non-key columns are included in the generated primary key. -
To ensure that only the intended columns are used, explicitly define the primary key in the pipeline YAML configuration.
tables:
- name: form_responses
primaryKeys:
- id
Defining
primaryKeysexplicitly helps ensure that incremental loads and upsert operations use the expected key columns rather than relying on automatically inferred schema constraints.
5. Enable Incremental Refresh in Bold BI
After the pipeline creates the associated data source:
- Open the generated data source.
- Enable Incremental Refresh.
- Select the same timestamp column (or equivalent tracking column) used by the pipeline’s replication_key whenever possible.4. Optionally configure unique identifier columns.
- Save the changes.
6. Schedule and Run the Pipeline
- Configure a schedule in Bold Data Hub.
- Run the pipeline manually or wait for the scheduled execution.
- Monitor the execution logs for successful completion.
7. Validate the Results
After the pipeline completes:
- Insert a new record in the source table and run the pipeline again.
Expected behavior:
- New records should be added to the destination.
- Existing records should not be duplicated.
- Record counts should not be duplicated, and record counts should increase only when new source records are added.
Important Concepts
Incremental Extraction
Incremental extraction is controlled by:
- replication_method
- replication_key
The system automatically maintains a checkpoint value after each successful execution and uses it during subsequent runs.
Important
replication_key controls which records are extracted.
It determines which records are extracted but does not control how records are merged into the destination table.
Duplicate Prevention - To avoid duplicate records, configure a primary key and use an upsert-based load method:
YAML
metadata:
<table_name>:
primary_key: ticketid
Always configure:
- A valid primary_key
- An upsert-based load strategy (when supported)
- A destination table with appropriate key constraints
Best Practices
- Define a primary key for every table.
- Use incremental extraction whenever possible.
- Configure an upsert load strategy to handle existing records.
- Ensure the replication key contains increasing or updated values.
- Validate record counts after each execution.
- Follow correct YAML syntax and indentation.
Expected Outcome
- After proper configuration:
- New records are extracted incrementally.
- Existing records are not duplicated.
- Pipeline execution remains efficient and scalable.
- Incremental refresh processes only the required data.