Kater CLI Make and compare new
kater new field
Makes a new field in a saved query, as the new-field form in Kater does.
You start with a field, turn it into something such as a running total, set it up, and name it. Kater shows the field’s Kater SQL, its definition and its first rows before it saves anything.
Examples
# Go to the ad_reporting workspace in your local copy of Kater contentcd connections/snowflake_prod_connection/workspaces/ad_reporting# Make a field step by step, with Kater asking for each stepkater new field --path query_contracts/paid_media_spend_trend.sql# List what sum__spend can turn into, and make nothingkater new field --path query_contracts/paid_media_spend_trend.sql --from sum__spend --list# Add the percent change of spend from the month beforekater new field --path query_contracts/paid_media_spend_trend.sql --from sum__spend --make previous_period --set output=percent_change --write# Add return on ad spend, as a measure written in Kater SQLkater new field --path query_contracts/spend_conversion_value_by_platform.sql --sql "EVAL(ad_reporting.sum__conversions_value) / NULLIF(EVAL(ad_reporting.sum__spend), 0)" --kind measure --label "Return on ad spend" --write# Add the same ratio as an Excel formulakater new field --path query_contracts/spend_conversion_value_by_platform.sql --excel "=[@sum__conversions_value]/[@sum__spend]" --label "Return on ad spend" --writeOptions
It also takes the global options --json, --kater-root, --scope and --help.
The four steps
| Step | Option | Example |
|---|---|---|
| Start with | --from FIELD | --from sum__spend |
| Turn it into | --make CHOICE: a recipe, or an operation from the field’s menu | --make running_total, --make comparisons.previous_period |
| Settings | --set NAME=VALUE, one for each setting | --set output=percent_change |
| Name it | --label, --name, --description | --label "Spend change" |
In a terminal and in a script
- In a terminal, it asks for each step that the options leave out, numbered as the form numbers them. Enter keeps the default, a number selects a choice, and
-leaves an optional step empty. It previews the field, asks before it adds it, and prints the one command that makes the same field. - Anywhere else, or with
--jsonor--no-input, it never asks. A step left open gets that step’s choices and exit code 0. A script then adds the next option. The choices arefield.options, as JSON when the output is not a terminal. --listanswers any step and makes nothing.- Without
--write, a script saves nothing.
The preview
The preview runs with the query’s own filters on, and every parameter at its default. --input sets one parameter.
Options that go together
--makeneeds--from, and--setneeds--make.--sqltakes the place of--from,--makeand--set.--exceltakes the place of--sql,--from,--make,--setand--kind.--listdoes not go with--sql,--excelor--write.- A filter cannot come from
--sql.