Skip to content

feat(incremental): opt PgSQL into two-mode incremental fetching [CFTL-771] - #172

Open
matyas-jirat-keboola wants to merge 7 commits into
masterfrom
cftl-771-incremental-fetching-window
Open

feat(incremental): opt PgSQL into two-mode incremental fetching [CFTL-771]#172
matyas-jirat-keboola wants to merge 7 commits into
masterfrom
cftl-771-incremental-fetching-window

Conversation

@matyas-jirat-keboola

Copy link
Copy Markdown

Part of the CFTL-771 two-mode incremental fetching rollout — this is the reference driver. Full plan: docs/superpowers/plans/2026-08-13-incremental-fetching-rollout.md.

What

Opts keboola.ex-db-pgsql into the two-mode incremental fetching feature:

  • PgSQL::getIncrementalFetchingColumnType() override — exposes the GenericStorage basetype (reused by validateIncrementalFetching()), enabling the shared window + watermark-lookback logic.
  • New datadir tests: incremental-fetching-window-late-commit (window mode) and incremental-fetching-lookback-late-commit (default watermark + lookback) — each proves a row committed below the watermark but inside the window/lookback is re-fetched (and, for lookback, that a row older than the margin is correctly excluded).

Modes (what the config exposes)

// default watermark mode, optional lookback (the late-commit fix)
{ "incrementalFetchingColumn": "ts", "incrementalFetchingLookback": "20 minutes" }
// window mode (backfill / bounded range)
{ "incrementalFetchingColumn": "ts", "incrementalFetchingMode": "window",
  "incrementalFetchingStart": "20 minutes ago", "incrementalFetchingEnd": "now" }

Review / merge notes (Option B batch)

  • Carries TEMPORARY dev-branch deps on all three shared libs (config/adapter/common #cftl-771); re-pinned to released ^1.17/^17.3 before merge.
  • CI is GREEN (this repo commits its lock, so composer install uses pinned refs): build + full PG 9–13 datadir matrix + tests-in-kbc (test project) all pass.
  • Validated in-platform on a test project (lookback re-fetches below the watermark) and confirmed working on a real timestamptz table.
  • Review together with the other CFTL-771 driver PRs. Do not merge before the cascade (config → adapter → common → drivers).

🤖 Generated with Claude Code

matyas-jirat-keboola and others added 5 commits August 12, 2026 11:13
…branches

Wires vcs repositories + aliased dev-branch requires for
keboola/db-extractor-config, keboola/db-extractor-adapter and
keboola/db-extractor-common so pgsql can consume the unreleased
incremental-fetching WINDOW feature from all three shared libs before
they are tagged. MUST be reverted back to the ^-range requires once
those repos cut real releases.
Extracts the GenericStorage basetype detection out of
validateIncrementalFetching() into a new
getIncrementalFetchingColumnType(ExportConfig): ?string, reused by
validateIncrementalFetching() for the existing INCREMENTAL_TYPES
check (unchanged void signature/behaviour). This overrides the
default-null hook in db-extractor-common's BaseExtractor, so PgSQL
is the first extractor to support the window feature (Start/End
bounds on incremental fetching).
Datadir test against a live Postgres table with distinct timestamps
(no ties, so row order is deterministic across the PG version test
matrix). One row's timestamp is BELOW the stored watermark in
source/data/in/state.json; without a window the old "col >=
lastFetchedRow" predicate would permanently skip it. With
incrementalFetchingStart set, the watermark is ignored and the row
appears in the output - the CFTL-771 late-commit fix.
…proof

Refresh the TEMP dev-branch deps (config/adapter/common) to the two-mode
build: explicit incrementalFetchingMode (watermark default | window),
with an optional watermark lookback (col >= watermark - N).

- window late-commit test: pin incrementalFetchingMode=window (the mode
  now gates whether the window keys are read).
- new lookback late-commit test: default watermark mode + a 10-minute
  lookback re-fetches a row committed below the watermark but inside the
  margin, while correctly excluding a row older than the margin.

Both incremental late-commit datadir tests pass against live Postgres.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…f3d7)

Refresh the config dev-dep so the watermark lookback always subtracts the
magnitude ("20 minutes ago" no longer flips to +20min) and preserves the
timestamptz offset in the emitted lower bound.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Aug 17, 2026

Copy link
Copy Markdown

CFTL-771

… test

- README: new "Incremental Fetching" section documenting incrementalFetchingMode
  (watermark default | window), incrementalFetchingLookback, and
  incrementalFetchingStart/End with types, semantics, and examples.
- push.yml: add a tests-in-kbc config (cf-tests-prod) that exercises numeric
  window + lookback on public.users, so the feature is smoke-tested against the
  freshly-built image in CI (mirrors the oracle/mssql in-platform tests).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
apt-key is removed in Debian 13; switch the PGDG key to a signed-by keyring. Off EoL bookworm per review.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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