Skip to content

feat!: report a load's committed rows to its caller after each commit - #407

Merged
kvlonge merged 3 commits into
mainfrom
feat/committed-rows
Dec 6, 2026
Merged

kvlonge merged 3 commits into
mainfrom
feat/committed-rows

Conversation

@kvlonge

@kvlonge kvlonge commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

Why

A program that embeds SQLLoad, such as SQLBuild, learns a load's rows only when load_tables returns, so a long load shows no progress. The load event stream already reports rows, but only to the one listener listen() sets up for the command line, and it reports rows read rather than rows committed.

Changes

  • Breaking: load_tables takes a fourth argument, committed: Option<CommittedRows>. Pass None to keep the old behaviour.
  • CommittedRows (sqlload::committed_rows::types) is called after each commit with the rows that load has committed so far, across all its tables and threads.
  • Each call to load_tables keeps its own total, so two loads running at once never see each other's rows. The total is added to and the callback called under one lock, so the totals a callback hears never go down.
  • It counts committed rows only, never rows read. A replace, recreate, --reload rebuild or files folder swap reports its rows once, when it swaps in. Child (unnest) tables are not counted as the load's rows.
  • listen(), the load event stream and LoadRun are unchanged.

Verification

  • A test runs two loads at once: a day-windowed delete_insert hears 2, 3, then 5, and a replace hears 5 once, each ending at the rows its tables report. It fails if the per-commit report is removed.
  • A files merge of 1,001 files hears 1,000 then 1,001, and its --reload hears 1,001 once. It fails if the rebuild is reported per commit.
  • Not tested: two tables of one load committing at the same moment. Only a test that fails some of the time could catch that, so the lock is checked by review instead.
  • cargo check, clippy and cargo fmt for sqlload (cli, duckdb), and fensu check. Clippy's new Some(x).filter lint and the fetch_update deprecation already fire in files this change doesn't touch.

load_tables takes a committed-rows callback, called with the load's running total.

BREAKING CHANGE: load_tables takes a fourth argument, committed: Option<CommittedRows>; pass None to keep the old behaviour.
A files merge loaded from 1,001 files hears each of its two commits, and
its --reload, which merges into a build table, hears the total once at the
swap. The committed-rows callback is documented as not panicking, and the
load_tables doc names files folder swaps and child tables.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

Deploying sqlload with  Cloudflare Pages  Cloudflare Pages

Latest commit: bf81a93
Status: ✅  Deploy successful!
Preview URL: https://13430de2.sqlload.pages.dev
Branch Preview URL: https://wip-committed-rows.sqlload.pages.dev

View logs

@kvlonge
kvlonge merged commit 402fa11 into main Dec 6, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant