Incremental Data Loading
Instead of reloading all data on every run, incremental loading fetches only new or changed records. This is faster, cheaper, and reduces API rate-limit pressure.
The specific incremental strategy you use depends entirely on what parameters your data source accepts. Some APIs offer cursor-based pagination, some accept date filters, and some have no incremental support at all. The two patterns below show how hibase's parameter query mechanism enables incremental loading — regardless of the underlying API's specifics.
The Mechanic: Parameter Queries
Both patterns work the same way:
- A parameter query runs against the target database to determine what data you already have
- The query result produces one or more parameters (e.g.
$last_id,$since_date) - These parameters are injected into the data source query or connector endpoint parameters via
{{ }}interpolation - The data source fetches only records beyond that point
This works identically for SQL data sources and connector data sources — the parameter query always runs against a database you control.
Pattern 1: Cursor-Based
Use this when the source data has a monotonically increasing value — an auto-increment ID, a sequence number, or any value that only grows.
Parameter Query (runs against the target database):
SELECT MAX(id) AS last_id
FROM my_schema.my_table
Then pass $last_id to your data source.
With a SQL data source:
SELECT * FROM source_db.records
{{ WHERE id > $last_id }}
On the first run, $last_id is NULL (empty target table). The {{ WHERE ... }} syntax handles this gracefully by dropping the clause entirely, fetching all records.
With a Connector Query:
Set the relevant endpoint parameter to {{ $last_id }}:
| Parameter | Value |
|---|---|
| cursor | {{ $last_id }} |
The parameter name (cursor, offset, after, etc.) depends on what the specific endpoint accepts.
Pattern 2: Date-Based
Use this when you want to fetch records based on a timestamp — common when syncing tables that track when rows were created or modified.
Parameter Query:
SELECT
COALESCE(MAX(updated_at), '2020-01-01') AS since_date
FROM my_schema.my_table
With a SQL data source:
SELECT * FROM source_db.records
{{ WHERE updated_at > $since_date }}
With a Connector Query:
| Parameter | Value |
|---|---|
| since | {{ $since_date }} |
The COALESCE in the parameter query provides a fallback date for the initial import (when the target table is empty). You can also pass this as a workflow parameter for flexibility.
Overlap for Safety
To catch late-arriving data, subtract a buffer from the start date:
SELECT
COALESCE(
DATE_SUB(MAX(updated_at), INTERVAL 2 DAY),
'2020-01-01'
) AS since_date
FROM my_schema.my_table
This re-fetches the last 2 days of data on each run. Combine with the Upsert on unique identifier strategy to avoid duplicates from the overlap.
Adding a Timestamp
Always add an imported_at timestamp to track when each row was imported:
| select_as | select_value | selector_type |
|---|---|---|
| imported_at | {{ $now }} |
custom_value |
Write Strategy
The right strategy depends on your incremental pattern and database engine:
- Cursor-based patterns that guarantee no duplicates work well with Insert only or Upsert on unique identifier
- Date-based patterns with an overlap window may re-fetch existing rows — use Upsert on unique identifier to avoid duplicates, or Insert only if your database is append-only and you handle deduplication downstream
Not all strategies are available on all databases. See Step Configuration for details.
Tips
- Always add an
imported_attimestamp for debugging and freshness monitoring - Use an overlap buffer for date-based imports to catch late-arriving data
- Set a fallback date via
COALESCEor workflow parameters for the initial import - Pair incremental imports with assertions to verify data freshness