Profiles, tests, diffs and plans

fonctionnel

Profile a result, test it with checks that show their evidence, compare results and runs, and read, compare and time query plans.

Run All on a notebook of order checks: a column profile, a Tests cell with one failing check and its rows, a year-over-year diff, then two runs compared in the History rail.

Real recording · typing sped up · Northwind demo data

Open the walkthrough on its own page

Five cell kinds help you check a result rather than just look at it: Profil describes every column, Tests checks rules and shows the evidence, Différence compares two results, Query plan explains and times a query, and Entity detail follows one record through its foreign keys. Each one reads another cell, picked with its Input picker, and runs when you run it.

Profile a result

A Profile cell shows a card for each column of its input: the type and its likely meaning (dates, emails, IDs, money and more), missing values, distinct values, the range, average and spread, percentiles (5th, median, 95th), outliers, a histogram, the five most frequent values, and whether the column could be a key. A summary grid lists every column with Missing %, Distinct, Min, Max, Average, Spread and Key, sortable by any of them.

SQLly
Profile cell with column cards and a summary gridProfile cell with column cards and a summary grid
A profile cell: column cards with histograms, and the summary grid sorted by missing values.

Profiles work in a fixed amount of memory. Counts are exact up to a point and then estimated, and any estimate is marked ≈. The banner says how much was read: "Profiled all 48,210 rows. Every figure is exact." or "Approximate: profiled 100,000 of 2,400,000 rows. Run the input in full for exact figures." A result that spilled to disk is profiled from the whole file. When the input is a table in the notebook's local data (an attachment, or a cell copied there) that holds more rows than its result shows, missing values, distinct values, ranges, averages and quartiles come from the whole table, computed by the local database: the banner says "Column statistics cover all 2400 rows of the local table (DuckDB). Histograms, top values and meanings cover the first 1000 rows." and each column card heads those figures Whole table (DuckDB) and the rest First 1000 rows. The summary grid uses the whole-table figures. A profile whose result already covers the whole table is profiled from its rows as before, because the local database's distinct count is an estimate. A column is only called unique when every row was read.

SQLly
Profile cell with Whole table (DuckDB) and First 1000 rows sections on a column cardProfile cell with Whole table (DuckDB) and First 1000 rows sections on a column card
A profile of an imported file: column statistics cover the whole local table, histograms and top values only the rows shown.

Tests

A Tests cell holds one or more checks on its input. Add checks of these kinds:

VérifierWhat it tests
Row countThe number of rows is between a minimum and a maximum.
UniqueOne or more columns have no duplicate values (rows with a NULL key are skipped, as in a UNIQUE constraint).
Not nullA column's share of NULLs is at most a limit (zero by default).
Value rangeA column's values are within a minimum and maximum.
Accepted valuesA column only holds values from a list, optionally ignoring case.
MotifA column's text matches a regular expression (linear-time, size-limited).
Matching keysEvery value of a column exists in a column of another cell (a foreign-key check across results).
Drift from baselineA column's distribution hasn't moved too far from the previous run or a pinned snapshot (PSI, KS distance or mean shift).
FreshnessThe newest timestamp in a column is recent enough. Timestamps stored without a time zone are read in the check's Fuseau horaire (blank means UTC); a timestamp in the future gives a warning.
Query durationThe input query ran within a time limit.
KPI thresholdA value compares as expected with a threshold.

Each check has a severity (error or warning) and an optional name, such as "one row per order". Press Run tests (or run the notebook). Each check shows Passez, Avertissement, Fail, Erreur ou Inconclusive with the numbers it saw, and a failing check offers Show failing rows with up to 20 of them in a grid.

SQLly
Tests cell showing a failed check with evidence and failing rowsTests cell showing a failed check with evidence and failing rows
A Tests cell with a failing check and its failing rows open.
  • No false alarms from partial data. When the input was cut short or sampled, a check reports Inconclusive instead of passing or failing, unless you allow partial data for that check.
  • Baselines. Drift checks compare with the Previous run ou un Instantané you pinned in the History tab; see Snapshots.
  • The notebook keeps count. The top bar shows "2 tests failing" (or "need attention", or "passing"), and Run All ends with "Run finished: 2 tests failing." Every run's failures are kept with their evidence in the run history. When you open the notebook again, the top bar shows each Tests cell's outcome from the newest recorded run that checked it, until a new run replaces it.
  • In CI. sqlly-cli notebook run exits with code 4 when a check fails; see exit codes.
SQLly
Notebook top bar showing the number of failing testsNotebook top bar showing the number of failing tests
The failing-tests count in the notebook top bar after Run All.

Diff two results

A Diff cell compares a Avant et un Après. Each side is a cell and one of:

  • Current result: the cell's result now.
  • Previous run: the same cell in the last recorded run.
  • Snapshot: …: a snapshot you pinned.
  • Re-run on …: the same SQL run again, read-only, on another of the notebook's connections, to compare development with production. That connection must be one you allowed when you trusted the notebook, and it must be set up on this computer ("That connection is not set up on this computer.").

Donnez Colonnes clés (comme id, region) to pair rows by key; without keys, rows are paired by position. Tolerance ignores numeric differences up to an amount (say 0.01 for rounding), and Ignore case et Ignore spacing compare text loosely. Large whole numbers and long decimals are compared digit for digit, never through floating point, unless you set a tolerance. Press Comparer: chips summarize added, removed, changed and unchanged rows (always exact), column changes are listed, and grids show the added, removed and changed rows (each change with before, after and the difference), up to 2,000 rows.

SQLly
Diff cell with summary chips and changed rowsDiff cell with summary chips and changed rows
A Diff cell comparing freight by country in 2022 and 2023: counts and a grid of changed values.

Each side is read up to 1,000,000 rows; past that the diff refuses rather than compare part of the data. A comparison is called conclusive only when both inputs are complete.

Plans de requête

A Query plan cell shows the plan of another cell's query, through the same plan viewer as a query tab (findings and the operator tree; see Plans de requête), on engines that support it.

  • Plan estimé never runs the query. Actual plan (runs the query) runs it once after you confirm: "An actual plan runs this query once on its connection, read-only." with Run actual plan. Both always use the read-only session, and both refuse a query with more than one statement: "A plan can only be captured for a single statement. Split the query into one statement per cell."
  • Compare with another cell's query (a rewrite) or the Previous run to see which operators got costlier or cheaper. The query you compare with goes through the same checks as running it, and must be on the same connection.
  • Explain with AI, beside the plan, adds an AI cell that explains the plan's most expensive steps and how the query might be made faster. See The AI notebook agent.
  • Session counters from the database are shown on SQL Server and MySQL, each figure labelled with the engine and where it came from.
SQLly
Plan cell comparing two query plansPlan cell comparing two query plans
A plan cell comparing the estimated plans of a JOIN version and a subquery version of the same query.
SQLly
Plan cell with the Explain with AI buttonPlan cell with the Explain with AI button
A plan cell's estimated plan, with the Explain with AI button beside its source.

Parameter sweeps

A plan cell can also time a query across a list of values for one parameter, a few runs each: at most 200 runs in all (values × repetitions, up to 20 repetitions). For each value it reports the mean, standard deviation, minimum, maximum and median, and says one value is faster or slower than another only when the difference is beyond two standard errors; otherwise "Within run-to-run noise". A sweep goes through the same permission checks as running the cell (trust, the connection, read-only), never runs a cell that changes data ("Sweeps only run read-only queries."), and on a production connection it asks first: "This sweep repeats the query on a production connection. Authorize this run?" with Authorize and run.

Entity detail

An Entity detail cell takes one record, a row from another cell's result (with Previous and Next to step through it) or a parameter value such as a customer ID. When the row comes from a Table cell, the Entity detail cell follows the row you select in that table's grid (through its sorting and filters) and fetches its related rows again once it has run. It shows the rows related to it through foreign keys, each in its own grid. Tick the relationships to follow under Relationships to follow: "Orders rows that point here (CustomerID)" or "Customers it points to (CustomerID)". Only ticked relationships are queried, read-only, at most 50 rows each by default (500 at most) and up to 12 relationships; rows with a NULL key are skipped. Open as detail on a related set adds a new Entity detail cell for it.

SQLly
Entity detail cell with a customer and related ordersEntity detail cell with a customer and related orders
An Entity detail cell showing customer ALFKI and its orders.

Limites

  • A diff side re-run on another connection uses the SQL as written for the cell's own engine.
  • A plan can't compare with a query on a different connection.
  • The CLI runs Tests cells but not Profile, Diff, Plan or Entity detail cells.
  • Only profiles of a local table use the whole table for their column statistics; a profile of a remote result reads the rows the result holds.