Skip to main content
On this page

Kater CLI Topics

Quick operations

Change a model's SQL through typed operations, and the options that document commands take.

Change a model’s SQL through these operations, and let the writer write it. kater source write is for what no operation expresses. Find the supported operations before you build an edit. Pass each returned target and operation_id with a parameters object that holds the values you selected.

FamiliesWhat they do
aggregations, derive, windows, comparisons, calculate_atAdd a field.
filters, sort, filter_by_this_numberChange a clause. filter_by_this_number is a number measure’s HAVING condition in a query, or its Top N in QUALIFY.
format, timeframes, fieldChange a field, or name or copy it. field.classify writes a field’s classification, and field.not_additive_across a measure’s non-additive rule.
Terminal window
# List the operations the AMOUNT field offers
kater operation list FILE --field AMOUNT --json
# Show what AMOUNT can be turned into
kater new field --path FILE --from AMOUNT --list
# Add the percent change from the previous period, without prompts
kater new field --path FILE --kind calculation --from AMOUNT --make previous_period --set output=percent_change --no-input
# Turn a running sum into a 6-period moving average, and save it
kater field edit --path FILE --field running_sum__amount --make moving_average --set size=6 --write
# Find the "is equal to" operation for the STATUS field
kater operation search 'is equal to' FILE --field STATUS --family derive --json
# Propose the edits in operations.json and save the proposal
kater model edit query.orders --path FILE --operations-file operations.json --json > proposal.json
# Apply the saved proposal
kater model edit query.orders --path FILE --apply-plan proposal.json --write --json
  • Keep ids intact. Keep source targets’ discovered relation ids and aliases as they are.
  • Raw datetime fields. Use --add-fields SOURCE.FIELD, and select the advertised timeframes operations for truncation.
  • Redirects need your own terminal. The > proposal.json redirect works in your own shell, not in the Files terminal or through an agent.

Document options

Document commands take --model REF, --at LINE:CHARACTER (zero-based UTF-16) and --text-file FILE where they apply. Completions require --at. Attached edits update the owning editor buffer. Standalone writes save files.

Terminal window
# Get completions at a position in an unsaved buffer
kater model inspect FILE --feature completions --at LINE:CHARACTER --text-file TEXT_FILE