Skip to main content

Run SQL expectation checks against a database.

Project description

small-expectations

Simple SQL-based expectations runner.

Install

pip install small-expectations

Usage

Create smallex.toml:

[database]
engine = "sqlite"

[database.connection]
database = "example.db"

Supported engines:

  • sqlite
  • snowflake
  • databricks

Example snowflake config:

[database]
engine = "snowflake"

[database.connection]
account = "my-account"
user = "my-user"
password = "my-password"
warehouse = "my-warehouse"
database = "my-database"
schema = "public"

Example databricks config:

[database]
engine = "databricks"

[database.connection]
server_hostname = "adb-1234567890123456.7.azuredatabricks.net"
http_path = "/sql/1.0/warehouses/abc123"
access_token = "dapi..."

Add SQL files under tests/:

SELECT * FROM users WHERE email IS NULL;

You can define multiple tests in one SQL file with metadata comments:

-- smallex:test: no_null_emails
-- smallex:message: users.email should never be null
SELECT id, email
FROM users
WHERE email IS NULL;

-- smallex:test: no_duplicate_emails
-- smallex:message: users.email should be unique
SELECT email, COUNT(*) AS duplicates
FROM users
WHERE email IS NOT NULL
GROUP BY email
HAVING COUNT(*) > 1;

Metadata markers:

  • -- smallex:test: <name>: logical test name (used in output as file.sql::<name>).
  • -- smallex:message: <message>: failure message shown in terminal summary and failure details.

Run:

smallex run

Show command help:

smallex run --help

A test passes when the query returns zero rows and fails if it returns one or more rows. The terminal report follows a pytest-like style (session header, per-test ./F, failure details, and short summary info).

Failure rows output

By default, failing rows are not printed or exported.

You can configure this behavior:

smallex run \
  --failure-rows-mode terminal \
  --failure-rows-limit 5
smallex run \
  --failure-rows-mode csv \
  --failure-rows-csv-limit 10000 \
  --failure-rows-dir .smallex/failures
smallex run \
  --failure-rows-mode both \
  --failure-rows-limit 5 \
  --failure-rows-csv-limit 10000

Options:

  • --config: path to TOML config file (default: smallex.toml)
  • --tests-dir: root folder containing .sql test files (default: tests)
  • --color: auto | yes | no (default: auto)
  • --failure-rows-mode: none | terminal | csv | both (default: none)
  • --failure-rows-limit: top rows shown in terminal per failing test (default: 5)
  • --failure-rows-csv-limit: max rows written to CSV per failing test (default: 10000)
  • --failure-rows-dir: output directory for CSV files (default: .smallex/failures)

Testing

The test suite includes:

  • CLI + SQLite integration tests using a temporary local database.
  • Backend unit tests that mock Snowflake and Databricks connectors so no real cloud connections are required.

Documentation

This repository uses MkDocs + Material.

Run docs locally:

pip install ".[docs]"
mkdocs serve

Build static docs:

mkdocs build

GitHub Pages is deployed automatically from .github/workflows/docs.yml on pushes to main.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

small_expectations-0.2.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

small_expectations-0.2.0-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file small_expectations-0.2.0.tar.gz.

File metadata

  • Download URL: small_expectations-0.2.0.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for small_expectations-0.2.0.tar.gz
Algorithm Hash digest
SHA256 67a694dc454c727057452d1a365e7780a4644098f05d1cf2f47a18dbd18ba063
MD5 4829227971b16a907984ac7f1085af4a
BLAKE2b-256 d3e8a0383e148c58142cd28850b62aaf3c0b23f46500e7e893c67efaf8339c83

See more details on using hashes here.

File details

Details for the file small_expectations-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for small_expectations-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f0d61f7bfa101494c8244521eeda651f5bfaa60ce120ed54ab5b161f7a020e1d
MD5 7d8633ec6b9d5d438d7ced79c7d4302f
BLAKE2b-256 f15713b58d48d6707fb8a476d2ab33048a57167af706fdddbd86b92645f0437c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page