Skip to main content
On this page

Kater CLI Build an analysis query

kater query compare

Compares two queries, or every query of two workspaces, and says where their rows differ.

Use it to check that a changed query still gives the same numbers. It runs the same comparison as kater compare, from a JSON request.

Examples

Terminal window
# Check that two queries give the same spend for each platform, with the request in compare.json
kater query compare --request-file compare.json
# Compare every query of ad_reporting with the same query in your brainstorm copy
echo '{"left": {"workspace": "connections/snowflake_prod_connection/workspaces/ad_reporting"}, "right": {"workspace": "connections/snowflake_prod_connection/users/you@example.com/brainstorm/promote_roas/workspaces/ad_reporting"}}' | kater query compare --request-file -

Arguments

ArgumentDescription
<path>Optional. In place of --request-file: the workspace, the query file or the chart file the request names.

Options

OptionDescription
--request-file <file>The JSON request. - reads it from standard input. See The request.

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

The request

This request compares spend_by_platform with spend_conversion_value_by_platform, row by row for each platform and currency:

compare.json
{"left": {"workspace": "connections/snowflake_prod_connection/workspaces/ad_reporting", "query": "spend_by_platform"}, "right": {"workspace": "connections/snowflake_prod_connection/workspaces/ad_reporting", "query": "spend_conversion_value_by_platform"}, "key": ["platform", "union__currency"]}
KeyWhat it holds
left, rightThe two sides. A side is a saved query, {"workspace": ..., "query": ...}, or a scratch statement, {"path": ..., "statement": ...}, counted from 0. A {"workspace": ...} alone on both sides pairs the queries of two workspaces by name. Paths are from the content root.
keyThe columns that pair a row of one side with a row of the other, by the left side’s names. Without it, Kater uses the row dimensions that both sides return. With none, it compares the sides as sets of rows.
columnsLeft columns to compare with a right column of another name, as an object. Each key is a left name, and its value is the right name.
parametersParameter values by name, for each side that declares the parameter. Otherwise each side runs at its defaults, with its own filters on.
precisionThe decimal places to compare numbers at, from 0 to 12, when that is finer than their format. Without it, numbers compare at their format’s places.

How it runs

Each side runs where you can already run it: a saved query as kater run runs it, and a scratch statement as the Sandbox runs it. Each pair runs as one warehouse statement that returns only the rows that differ, one pair at a time.

See also