catalog rebase
Re-derive an entry over its live sources and catalog it as a new entry.
Run it once xorq catalog check-sources reports a changed source. The recorded expression is rebuilt over the schemas the sources have now; the old entry is never edited or removed. The new entry keeps the old one’s wheels and requirements; xorq catalog show prints its ancestor and each –swap. A rebuild already cataloged adds nothing (–json: created is false). Only a lost column an op reads conflicts, yet the output schema can change: check stderr’s Output: line before moving aliases.
–dry-run writes nothing to the catalog (it may fetch the entry’s archive, as any rebase does): it prints the hash a rebase would produce, says what it would do to the aliases, and exits 3. It does not run the sync’s pull, so a synced rebase can still refuse an alias the pull moved. –no-add writes the rebased build to BUILDS_DIR/xorq catalog add on that directory yields the same hash, as long as the directory keeps its name, which add takes as the entry’s. A directory already at that path is never replaced: the rebase is refused before building. It does not sync, and takes no –alias, –move-aliases or –only-alias, since there is no entry to name. An interrupted –no-add can leave a hidden BUILDS_DIR/.
No alias moves unless asked. –move-aliases moves every alias the old entry has once the sync’s pull is in, and names any the pull took off it; –only-alias moves just the ones it names, each of which must be on the old entry or, after the pull, already on the new one (a rerun after a failed push). –alias registers another, and is refused if it points at any entry but the old or the new one; one already on the old entry moves. Aliases left on the old entry are named on stderr. Alias options apply only to a new entry: with no drift nothing is written and they are ignored, which stderr says, though –only-alias must still name the old entry’s aliases. A synced rebase stopped after its pull leaves what the pull merged in place; when the local catalog then has a commit its remote lacks, stderr says so (with –json, unpushed is true), and xorq catalog sync pushes it.
Prints the resulting entry name on stdout, and the detail on stderr. With no drift that name is the entry’s own, and nothing is committed. An entry with no source check-sources can probe (it names those it cannot; one that is down is unreachable instead) is left alone: its own name is printed, and stderr says drift was not ruled out.
A renamed column is a removed one to rebase, unless –rename says which live column it is now: --rename t a b reads t’s recorded column a from its live column b, and every op over t still sees a. SOURCE is a source’s name as check-sources prints it; OLD is a column it recorded, and a later rebase of the result keeps following the rename. Rebase never guesses a rename; a conflict over a lost column lists what each changed source lost and gained. A –rename is refused, every one in a single run, when SOURCE names no source, or sources on several connections; when OLD is not recorded, or is still live (so also with no drift); when NEW is not live; or when no source can be probed. One that renames a column of its source twice, maps two to one, or renames one to itself is an invalid option. A NEW the source had recorded too is allowed, with a warning: rebase can’t tell a mistyped NEW from a column dropped and replaced by the renamed one.
–swap points a table source somewhere else: --swap t u reads table u, in t’s namespace on t’s connection, wherever the entry read t. OLD is a source’s name as check-sources prints it, found as –rename finds one; u is probed against what t recorded, and the rebase goes on as over drift, so a swap is a new entry even with no schema change, and one u no longer fits conflicts. A read swaps to one path NEW, read by the same method and options; a multi-path read is OLD by its paths joined with “,”. A bundled read is OLD by its archive path (reads/aux.t t does). One that swaps a source to itself, twice or to an empty name is an invalid option. A –rename beside it names the swapped source by OLD, as recorded, and its conflict hints do too. Once every source is probed, a swap is refused beside any source it leaves that changed, is gone or could not be probed: rebase without –swap first, so each new entry carries one kind of change; a swap of every source never is. A source whose table is gone conflicts; –swap it onto its replacement.
–profile NAME moves every swapped source onto the connection of the profile saved as NAME, by Profile.from_con(con).save(alias=NAME) (--swap t t --profile prod reads t there). It needs a –swap; an unsaved NAME is an invalid option, and a swap onto its own table on its own connection is refused. NAME may be another backend type: the rebuilt entry is compiled for each backend it runs on, and an op that backend cannot compile conflicts.
Exit codes: 0 no drift, drift not ruled out (no source could be probed), or the rebase succeeded 1 refused, or failed: the name does not resolve, the catalog does not open, the entry is pinned, some but not all of its sources cannot be probed, the entry was built on another Python minor or records none (–ignore-venv-mismatch overrides it, with a warning), –only-alias names an alias on neither the old entry nor the new one (an unregistered one before the probe), –alias names an alias on another entry than the old or new one (once there is a new entry), ENTRY is an alias the pull moved or removed, a –rename or –swap is refused (see above), a probed source matched no source of the loaded expression, –no-add found its BUILDS_DIR/xorq catalog sync (pull, then push) finishes it
With –json, stdout is one document, printed once the rebase has ended and nothing else; its state and exit_code sit at the root, and the exit code is the process’s. Every outcome of rebasing a resolved entry prints one, a failed write included; a warning the rebase raises goes in its warnings, not on stderr. A rebase that never started (the name does not resolve, the catalog does not open, or the options are invalid) prints none, only the error on stderr. Its shape is documented in xorq.catalog.rebase.
Usage
xorq catalog rebase ENTRY [OPTIONS]Arguments
ENTRY—An entry name or alias.
Options
| Option | Default | Description |
|---|---|---|
--sync / --no-sync |
--sync |
Push the catalog to its remotes after the operation. |
--cache-dir |
$XORQ_CACHE_DIR or ~/.cache/xorq |
Directory for parquet cache files. |
-a, --alias |
none | Register this alias for the new entry. |
--move-aliases |
off | Move all of the source entry’s aliases onto the new entry. |
--only-alias |
none | Move only this alias of the source entry onto the new entry (repeatable). |
--ignore-venv-mismatch |
off | Proceed even if the entries’ wheel requirements or Python minor differ. |
--dry-run |
off | Report the hash a rebase would produce, and catalog nothing. |
--add / --no-add |
--add |
Catalog the rebased build; –no-add only writes its build directory. |
--builds-dir |
none | Where –no-add writes the build directory (default: builds); only with –no-add. |
--rename |
none | Read SOURCE’s recorded column OLD from its live column NEW, keeping the name OLD (repeatable). |
--swap |
none | Re-point the source OLD to the table NEW beside it, or an external read to the path NEW (repeatable). |
--profile |
none | Move every –swap onto the stored profile NAME’s connection. |
--json |
off | Output as JSON. |
Examples
xorq catalog rebase prod-matches
xorq catalog rebase prod-matches --move-aliases
xorq catalog rebase prod-matches --only-alias prod -a matches-v2
xorq catalog rebase prod-matches --json
xorq catalog rebase prod-matches --dry-run
xorq catalog rebase prod-matches --no-add --builds-dir builds
xorq catalog rebase prod-matches --rename matches team_id team
xorq catalog rebase prod-matches --swap matches matches_v2
xorq catalog rebase prod-matches --swap data/m25.parquet data/m26.parquet
xorq catalog rebase prod-matches --swap matches matches_v2 \
--rename matches team_id team
xorq catalog rebase prod-matches --swap matches matches \
--swap teams teams --profile prodSee also
catalog check-sources—find the entries whose sources moved- Check catalog entries for source drift—what each verdict means