check_against_source
Verify an output table against its raw source when no prior version exists, catching silent value conflicts, mismatched values, missing rows, and orphan rows.
Instructions
Check an output table against the raw source it was built from, when there is no "before" to compare.
It catches a transformation that looks clean but decided something it had no basis for: the source
sent two different amounts for one key and the output kept one without saying so, values that no
longer match the source, source rows that never arrived, or output rows with no source at all.
Use this for a new table, a first load, or a dedupe or repair step, where compare_tables has nothing
to compare with. Use compare_tables when you do have the table from before the change; you can run
both for the strongest check.
Behavior: read-only and repeatable. The table and the source are each read once (files are opened
read-only; Snowflake, dbt and SQL sources run one SELECT each, with credentials already configured
on this machine) and loaded into a temporary in-memory DuckDB. Nothing is written anywhere. Usually
takes seconds. Fails with a readable error if a file, table, key or column does not exist.
Returns verdict ("pass", "review" or "block"), headline (one sentence you can show the user), and
tables: one entry with stats and findings, each with check, severity, message, column and metrics.
A "review" here usually means the source itself is ambiguous, so a person must choose; say so.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"table": "<table>",
"source": "<source>",
"key": "<key>"
},
"name": "check_against_source"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Column or columns that identify one row in the output, for example ["txn_id"]. | |
| name | No | Name to show for the table in the report. Defaults to 'table'. | |
| table | Yes | The output table to check (for example a silver or gold table). A file path (.csv, .parquet, .json, .xlsx; CSV and JSON may be .gz or .zst), 'duckdb:<file.db>:<table or SELECT>', 'snowflake:<DB.SCHEMA.TABLE or SELECT>', 'dbt:<model>', or an object such as {"dbt": "fct_orders", "project_dir": "analytics", "target": "prod", "manifest": "prod-manifest.json"}, {"snowflake": "DB.SCHEMA.T", "connection": "name", "where": "..."} or {"url": "<SQLAlchemy URL>", "table": "schema.table"}. Relative paths are relative to the server's working folder. | |
| where | No | SQL filter for the source rows that should reach the output, for example "status <> 'test'". Omit when every source row should. | |
| checks | No | Which checks to run, from: conflict (the source has conflicting values for a key and the output silently kept one), mismatch (an output value differs from its source value), missing (a source key is absent from the output), orphan (an output key is absent from the source). Defaults to ["conflict"]. | |
| source | Yes | The raw input the output was built from (for example the bronze table or landing file). Same forms as 'table'. | |
| columns | No | Columns to compare, as {output column: source column}, for example {"amount": "amt"}. Needed for the conflict and mismatch checks; omit to check only keys. | |
| source_key | No | The key column or columns in the source, in the same order as 'key', when they are named differently. Omit if the names match. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tables | Yes | ||
| seconds | Yes | ||
| verdict | Yes | ||
| version | Yes | ||
| headline | Yes |