Skip to content

Guides

Reload a window

Replace a window of recent and future rows on every run, such as 7 days ago to 7 days ahead, with delete_insert, lookback, lookahead and lookback_from.

Some tables keep changing after their rows are written and hold future dates, such as deliveries scheduled ahead or bookings. Replacing a fixed window around today on every run keeps them right without reloading the whole table. This guide reloads from 7 days ago to 7 days ahead.

[sources.app.tables."public.deliveries"]
description = "Deliveries, one row each, scheduled up to two weeks ahead."
write_strategy = "delete_insert"
cursor_column = "delivery_date"
lookback = "7d"
lookahead = "7d"
lookback_from = "now"
Setting Here
write_strategy = "delete_insert" Deletes the window’s rows, then inserts what it read. Needs no key.
cursor_column The date or timestamp the window is on.
lookback How far back the window starts.
lookback_from = "now" Count lookback from the time of the run, not the destination’s maximum.
lookahead Read only values before now plus this; a date cursor reads up to and including today plus that many days.

plan shows the window on the table’s reads line. On 14 November 2026:

$ sqlload plan -v
…
Loads (1) sqlload load
└── raw.app__deliveries delete_insert (cursor: delivery_date)
├── source postgres app public.deliveries
├── route read as Arrow -> DuckDB takes Arrow
├── reads delivery_date from 2026-11-07 (now minus lookback 7days), below 2026-11-22 (now plus lookahead 7days)
└── commits once, at the end of the read (delivery_date isn't read in order)
…

Every run replaces 7 to 21 November. A delivery deleted at the source while its date is in the window is deleted from the destination too.

  • Days are counted in UTC; a date cursor moves by whole days. A timestamp cursor reads from exactly now minus lookback to now plus lookahead.

  • The first run reads the same window, so older rows never load. To fill the table, run --reload once (below), or backfill a range.

  • --start-cursor and --end-cursor replace the window for one run:

    $ sqlload plan --start-cursor 2026-10-01 --end-cursor 2026-11-01
    …
    ├── reads delivery_date from 2026-10-01 (--start-cursor), below 2026-11-01 (--end-cursor)
    …
  • --reload rebuilds the table from cursor_start, or from the first row, up to the lookahead:

    $ sqlload plan --reload
    …
    ├── reads delivery_date: reload, everything, below 2026-11-22 (now plus lookahead 7days)
    …
  • --reload --start-cursor rebuilds from that point and drops older rows; see Reloading.

Without it, lookback counts back from the destination’s maximum, so each run re-reads a window behind the newest row, here 2 hours, and everything after:

[sources.app.tables."public.page_views"]
description = "Page views, one row per view."
write_strategy = "delete_insert"
cursor_column = "viewed_at"
lookback = "2h"

That suits late rows, but not future dates, whose maximum is already ahead of today. lookahead works with either.

  • lookahead and lookback_from = "now" need a date or timestamp cursor.
  • lookback_from = "now" needs a duration lookback, such as "1d".
  • append takes no lookback, which would insert the window again; use delete_insert, or merge when the table has a key.
  • A files target takes neither lookahead nor lookback_from = "now": its window follows its newest partition.
  • Python tables take lookback, but not lookahead or lookback_from.

See Cursors and delete_insert.