Skip to content

Add upload-chain to start a job from a previous job's finished output - #15

Merged
rorylshanks merged 1 commit into
mainfrom
upload-chain
Oct 12, 2026
Merged

rorylshanks merged 1 commit into
mainfrom
upload-chain

Conversation

@rorylshanks

Copy link
Copy Markdown
Collaborator

What

New command partforge upload-chain -source-job-id=<finished-job-id> that starts a new job whose source is the finished output of a previous job.

partforge upload-chain \
  -source-job-id=<finished-job-id> \
  -destination-schema-file=dest_v3.sql \
  -insert-select-file=insert_v3.sql \
  -bucket=partforge
  • Each non-superseded, non-empty finished artifact of the source job becomes one READY source part of the new job.
  • Only a manifest.json is uploaded per part (no data copy). New manifest field s3.source_finished_key points at the parent's finished prefix.
  • The worker downloads that prefix, extracts all part tarballs, and attaches every part to the source table before running the insert-select.
  • The new job's source table/schema is the parent job's destination table/schema, so the insert-select reads FROM the parent's destination table.
  • -clickhouse-build defaults to the parent job's build; -copy-sql-from-job is supported.

Why

Lets a second rewrite run over an earlier rewrite's output without importing into ClickHouse and re-freezing.

Reviewer notes

  • The source job must be fully finished (all non-SUPERSEDED rows FINISHED/IMPORTING/IMPORTED); otherwise the command fails with per-status counts.
  • When a chained artifact contains more than one physical part, the worker disables insert chunking for that item (_part_offset ranges only partition a single part) and runs one insert. Single-part sources behave as before.
  • Parent artifacts are not protected: delete-job -delete-s3, reset-job, or reset-compaction on the parent before the chained job finishes rewriting will break it. This is documented, not enforced.
  • The e2e chain step exercises a single-part parent artifact; the multi-part fallback is not covered by e2e.

Testing

  • go mod tidy, go test ./... pass.
  • ./e2e/run.sh passes. New step chains e2e-job into dst.events_v3, verifies no source data was copied, runs workers, imports, and diffs against e2e/expected-chain.tsv.

🤖 Generated with Claude Code

New `partforge upload-chain -source-job-id=<job>` registers each finished
artifact of a fully finished job as a READY source part of a new job. Only
manifests are written; the new manifest field `source_finished_key` points
at the parent's finished prefix, and workers download and attach every part
tarball in it before running the new insert-select. The new job's source
table and schema are the parent job's destination table and schema.

Multi-part chained sources fall back to a single unchunked insert because
_part_offset chunk ranges only partition one part.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rorylshanks
rorylshanks merged commit 8fdae11 into main Oct 12, 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