Modes
Here are the various loading modes available. All modes load into a new temporary table prior to final load.
full-refresh
This is the default mode. The target table will be dropped and recreated with the source data.
incremental
The source data will be merged or appended into the target table. If the table does not exist, it will be created. See below for more details.
truncate
Similar to full-refresh, except that the target table is truncated instead of dropped. This keeps any special DDL / GRANT applied.
snapshot
Appends the full dataset with an added timestamp column. If the target table exists, Sling will insert into / append data with a _sling_loaded_at column. If it does not, the table will be created.
backfill
Similar to incremental, but takes a range input to backfill a specific update_key range, such as dates or numbers.
definition-only
Creates the target table or file structure without transferring any data. For database targets, the table is created with the inferred schema but 0 rows. For file targets, only Parquet and Arrow formats are supported, creating a file with proper column types but no data rows.
change-capture
Captures row-level changes (inserts, updates, deletes) from the source database's transaction log. Performs an automatic initial snapshot on the first run, then reads incremental changes on subsequent runs. Requires a primary_key. See Change Capture (CDC) for details.
Incremental Mode Strategies
New Data Upsert (update/insert)
yes
yes
Only new records after max(update_key)
Full Data Upsert (update/insert)
yes
no
Full data
Append Only (insert, no update)
no
yes
Only new records after max(update_key)
First Run & Bootstrap
What happens on the very first incremental run, when the target table is empty or does not exist:
The target table is auto-created. If the target does not exist, Sling creates it with column types inferred from the source data. You do not pre-create the table.
The first run reads the full source table. With no target rows and no stored watermark, there is no
max(update_key)to filter on, so Sling reads every row (the incrementalWHEREis effectively1=1). It then recordsmax(update_key)as the watermark. Every later run pulls only rows whereupdate_key > watermark.primary_keyandtable_keysare applied on that create. The keys you set (primary_key, plus anytarget_options.table_keyssuch as an index or partition) are applied when Sling creates the table, not on a later run.
An empty-but-existing target behaves the same as a missing one: with no rows, max(update_key) is null, so the first run reads the full source and seeds the watermark from it.
Watermark Safety (late-arriving data)
When a strategy pulls "only new records after max(update_key)", Sling computes the watermark as max(update_key) in the target table and pulls source rows where update_key > watermark. This is a boundary condition to understand:
A row that lands in the source with an
update_keyvalue at or below the current watermark (for example a late-arriving event, or a backdated correction) is not picked up by the next incremental run — its key is not greater than the last maximum.With a primary key set, rows whose key is greater than the watermark are upserted (updated in place). Rows below the watermark are simply not selected, so no update happens for them.
To catch late data, add a lookback / buffer by writing a custom-SQL stream with the {incremental_value} placeholder and subtracting an interval from the boundary:
With a primary key, the re-scanned rows are upserted, so re-reading them is idempotent (no duplicates). Choose the interval to cover your worst-case lateness; a wider buffer re-reads more rows each run. See Incremental or Backfill Mode With Custom SQL below for the placeholder details.
Incremental or Backfill Mode With Custom SQL
When using incremental or backfill mode with a custom SQL stream, Sling provides two placeholder options to handle incremental loading:
{incremental_where_cond}: Injects a complete WHERE condition{incremental_value}: Injects only the value, allowing for custom condition logic
Using {incremental_where_cond}
This placeholder injects a complete WHERE condition based on the update_key:
Sling will replace the placeholder as follows:
First run (table doesn't exist):
WHERE 1=1Subsequent runs:
WHERE my_update_key > '[incremental_value]'
For example, if the last maximum value was '2001-01-01 01:01:01', the query becomes:
Using {incremental_value}
This placeholder gives you more control over the WHERE condition by injecting only the value:
Sling will replace the placeholder as follows:
First run (table doesn't exist):
{incremental_value}becomesnullSubsequent runs:
{incremental_value}becomes the last maximum value
For example, if the last maximum value was 99, the query becomes:
Last updated
Was this helpful?