Skip to main content
On this page

Kater CLI Make and compare

kater diff

Says whether two answers are the same and shows where they differ.

Use it to check that a changed query, or a copy of a workspace, still returns the same rows. Each pair runs on the warehouse as one statement that returns only the rows that differ.

Examples

Terminal window
# Go to a connection in your local copy of Kater content
cd connections/snowflake_prod_connection
# Check that two queries return the same spend by platform and currency
kater diff --left workspaces/ad_reporting/spend_by_platform --right workspaces/ad_reporting/spend_conversion_value_by_platform
# Diff every query of the workspace with your brainstorm copy of it
kater diff --left workspaces/ad_reporting --right users/you@example.com/brainstorm/promote_roas/workspaces/ad_reporting
# Diff one query with your copy of it, over the last 6 complete months
kater diff --left workspaces/ad_reporting/paid_media_spend_trend --right users/you@example.com/brainstorm/promote_roas/workspaces/ad_reporting/paid_media_spend_trend --parameter is_within_last__union__date_day=6
# Diff the first two statements of a scratch file
kater diff --left users/you@example.com/brainstorm/promote_roas/spend_check.sql#0 --right users/you@example.com/brainstorm/promote_roas/spend_check.sql#1

Options

OptionDescription
--left <side>The first side. Give a query as <workspace>/<name> or by its id. Give a scratch statement as its file, # and its number, counting from 0, such as spend_check.sql#0. Or give a workspace by its folder or its id, whose queries pair by name with the other workspace’s.
--right <side>The second side, given in the same way. A workspace pairs only with another workspace.
--key <column>A column that pairs a row of one side with a row of the other, by the left side’s name. Without it, rows pair on the dimensions that both sides return. When there are none, the command diffs all the rows, in any order. You can give it more than one time.
--column <left>=<right>Pairs a left column with a right column that has another name. You can give it more than one time.
--parameter <name>=<value>Sets a parameter on every side that declares it. The command reads the value as JSON, or else as text. You can give it more than one time.
--precision <n>Diffs numbers at this many decimal places, from 0 to 12, where that is finer than their format.

It also takes the global options anywhere on the line, and --help.

What each pair says

Each pair has a status, which --json gives, and a result in words, which the command prints first on the pair’s line, such as 3 of 10 rows differ, Same in all 39 rows or Does not compile. A result check of a query with more than 10,000 rows compares a sample of them, and its words count the compared rows, such as 5 of 10,000 compared rows differ.

StatusWhat it means
sameEvery row and column of the pair matches.
differentSome rows differ. It gives the first 50 differences. A difference is a value that differs, or a row that only one side has. It can also be a key that more than one row on one side has, counted for each side.
only_left, only_rightAcross two workspaces, a query that only one of them has.
refusedA side could not run, and the result and the message say why. For example, it does not compile, or you cannot read it. A pair that the warehouse could not run reads Could not check. The other pairs still run.

The command prints each pair’s result and message, and its first 10 differences. The last line counts the pairs by result, such as 3 pairs: 1 same, 1 different, 1 could not check. --json gives every difference, and the first 10 rows that both sides have alike. A difference does not fail the command. It exits with 1 only when no pair differs and at least one pair is refused.

How it diffs

  • Defaults apply. Each side runs with each filter as its call says (a required filter on, an optional filter on only with on=TRUE) and each parameter at its default, except the parameters that --parameter sets.
  • Columns pair by name, after --column gives a left column its right name. A column that only one side returns is listed, and not diffed.
  • Numbers are diffed at the decimal places that their format shows. A number with no format must match to one part in a billion.
  • Paths that start with connections/ are from the content root. Other paths are relative to the folder you are in, or to --kater-root when you give it.

What it can diff

  • Queries diff from connection workspaces and from your own workspaces. A query in another person’s private workspace is refused.
  • Scratch statements run as kater show runs them.
  • One connection. Both sides must read the same connection. A side that diff does not run, such as custom SQL, is refused.
  • A copy and its original. Across a brainstorm copy and the workspace that it copies, changed marks each query that the copy changed. See Workspace copies.

Through the MCP

Through the Kater MCP, the result’s app_url opens it in Kater. A copy and its original open on the copy’s diff view, at the query that the chat’s card opens on. Any other diff opens at the left side’s place.

See also