Skip to main content
On this page

Kater CLI Build an analysis workspace

kater workspace apply

Writes the changes in a brainstorm copy back to the workspace it was copied from.

Use it when a change that you tested in a copy is ready. Only the files that the copy changed are written, and the copy’s copied-from.yaml names the original.

Examples

Terminal window
# Go to your promote_roas brainstorm topic in your local copy of Kater content
cd connections/snowflake_prod_connection/users/you@example.com/brainstorm/promote_roas
# See each file's diff and compare each query in the original and the copy, and save nothing
kater workspace apply workspaces/ad_reporting --dry-run
# Write the copy's changes back to the ad_reporting workspace
kater workspace apply workspaces/ad_reporting
# Write back only the spend_by_platform query
kater workspace apply workspaces/ad_reporting --files query_contracts/spend_by_platform.sql
# Write exactly what a dry run proposed, and stop when the proposal changed since
revision=$(kater workspace apply workspaces/ad_reporting --dry-run --json | jq -r .revision)
kater workspace apply workspaces/ad_reporting --revision "$revision"

Arguments

ArgumentDescription
<copy>The brainstorm copy to apply, by its folder, such as workspaces/ad_reporting in a brainstorm topic. The path is from the folder you are in, or from --kater-root when you give it.

Options

OptionDescription
--files <file>Applies only this file. Give its path in the copy, or its path in the workspace, such as query_contracts/spend_by_platform.sql. A file that the copy deleted is deleted only when you name it here. You can give it more than one time.
--dry-runShows each file’s diff and whether it would be written, and compares each query in the original and the copy. It saves nothing.
--revision <revision>The revision from a dry run’s apply line. The apply writes only while the proposal is still the same. Otherwise it stops with proposal_changed.

It also takes the global options --json, --kater-root, --scope and --help.

What it writes

  • Only changed files. Kater writes only the files that the copy changed since it was copied or last applied. Each file points back at the original workspace.
  • A file that only the original changed stays as the original has it.
  • No force. When the original changed a file since the copy was made, Kater refuses the file with origin_changed and both revisions. Make a fresh copy and make the change there.
  • It compiles first. The copy’s Kater SQL compiles together with the rest of the original, as any save does. A copy that does not compile there writes nothing and names each file’s errors.
  • Deletes need a name. A file that the copy deleted is deleted only when --files names it. Kater does not delete a query that a chart in the original still reads.
  • Apps stay. An app in the copy is not applied. The original’s apps stay with it, and a draft app has its own place, brainstorm/<topic>/apps/.
  • Each file’s outcome is reported. The apply is not all or nothing. Afterwards the copy’s record matches again, so the next apply sends only later changes.
  • Access. When you can only read the original workspace, only its owner or an administrator can apply the copy. A file that is open in the editor is not written. Close it or save it there, then apply again.

The dry run

A dry run gives each file’s diff, within one shared budget. A file that --files names shows its diff even past that budget. It also compares the original and the copy query by query, as kater compare does. Each query takes a few seconds. It ends with the apply line, whose --revision writes exactly that proposal.

After the apply

apps lists the apps that read the original workspace. kater brainstorm show checks one app. kater compare, with the original on the left and the copy on the right, then shows every query the same.

In a chat

Through the Kater MCP, the kater tool runs the dry run. The kater_apply tool runs the apply, after the person says yes. The agent reads each query’s verdict, and the person’s card shows each query’s rows before and after. --json returns the workspace.apply_copy answer.

See also