On this page
Kater CLI Build an analysis query
kater query diff
Diffs 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 diff as kater diff, from a JSON request.
Examples
# Check that two queries give the same spend for each platform, with the request in diff.jsonkater query diff --request-file diff.json# Diff every query of ad_reporting with the same query in your brainstorm copyecho '{"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 diff --request-file -Options
It also takes the global options anywhere on the line, and --help.
The request
This request diffs spend_by_platform with spend_conversion_value_by_platform, row by row for each platform and currency:
{"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"]}| Key | What it holds |
|---|---|
left, right | The two sides. A side is a 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. |
key | The columns that pair a row of one side with a row of the other, by the left side’s names. Without it, the diff uses the row dimensions that both sides return. With none, it diffs the sides as sets of rows. |
columns | Left columns to pair with a right column of another name, as an object. Each key is a left name, and its value is the right name. |
parameters | Parameter values by name, for each side that declares the parameter. Otherwise each side runs at its defaults, with each filter as its call says. |
precision | The decimal places to diff numbers at, from 0 to 12, when that is finer than their format. Without it, numbers are diffed at their format’s places. |
How it runs
Each side runs where you can already run it: a 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.