{"id":47883198,"url":"https://github.com/llucmh/dbt-checks","last_synced_at":"2026-05-16T02:04:56.781Z","repository":{"id":343108850,"uuid":"1099372452","full_name":"LlucMH/dbt-checks","owner":"LlucMH","description":"Reusable, declarative data quality checks for dbt projects.","archived":false,"fork":false,"pushed_at":"2026-04-03T23:11:28.000Z","size":2006,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-03T23:26:18.003Z","etag":null,"topics":["analytics","analytics-engineering","bigquery","data-quality","data-quality-checks","data-validation","data-validation-library","databricks","date-engineering","dbt","duckdb","postgres","snowflake","sql","testing","testing-framework","testing-tool"],"latest_commit_sha":null,"homepage":"https://github.com/LlucMH/dbt-checks","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LlucMH.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-18T23:02:38.000Z","updated_at":"2026-04-03T23:09:27.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/LlucMH/dbt-checks","commit_stats":null,"previous_names":["llucmh/dbt-checks"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/LlucMH/dbt-checks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LlucMH%2Fdbt-checks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LlucMH%2Fdbt-checks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LlucMH%2Fdbt-checks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LlucMH%2Fdbt-checks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LlucMH","download_url":"https://codeload.github.com/LlucMH/dbt-checks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LlucMH%2Fdbt-checks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31384847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T01:22:39.193Z","status":"online","status_checked_at":"2026-04-04T02:00:07.569Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analytics","analytics-engineering","bigquery","data-quality","data-quality-checks","data-validation","data-validation-library","databricks","date-engineering","dbt","duckdb","postgres","snowflake","sql","testing","testing-framework","testing-tool"],"created_at":"2026-04-04T02:01:33.675Z","updated_at":"2026-05-10T02:58:33.396Z","avatar_url":"https://github.com/LlucMH.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"assets/dbt-checks banner.png\" alt=\"dbt-checks banner\" width=\"600\"/\u003e\n\u003c/p\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/LlucMH/dbt-checks/ci.yml?branch=main\" /\u003e\n  \u003cimg src=\"https://img.shields.io/badge/dbt-1.5%2B-orange\" /\u003e\n  \u003cimg src=\"https://img.shields.io/badge/tested%20on-duckdb-blue\" /\u003e\n  \u003cimg src=\"https://img.shields.io/badge/cross--db-dbt%20dispatch-lightgrey\" /\u003e\n  \u003cimg src=\"https://img.shields.io/github/license/LlucMH/dbt-checks\" /\u003e\n  \u003cimg src=\"https://img.shields.io/github/v/release/LlucMH/dbt-checks\" /\u003e\n\u003c/p\u003e\n\n---\n\n**`dbt-checks`** is a lightweight library of reusable data quality checks for dbt projects.\n\nIt provides simple, expressive tests to validate business rules and data integrity directly in your models — without writing custom SQL every time.\n\n\u003e ⚠️ Early-stage project — feedback and contributions are welcome.\n\n---\n\n# Installation\n\nAdd the package to your `packages.yml`:\n\n```yaml\npackages:\n  - git: https://github.com/LlucMH/dbt-checks.git\n    revision: v0.3.2\n```\n\nThen install dependencies:\n\n``` bash\ndbt deps\n```\n\n💡 Always pin a version in production projects.\n\n# Usage\n\nChecks can be added directly to models or columns in your schema files.\n\nExample:\n\n``` yaml\nmodels:\n  - name: orders\n    columns:\n      - name: value\n        data_tests:\n          - dbt_checks.non_negative\n          - dbt_checks.between_values:\n              arguments:\n                min_value: 0\n                max_value: 10000\n```\n\nRun tests as usual:\n\n``` bash\ndbt test\n```\n\n# Scoped Checks with `where`\n\nAll checks support an optional `where` argument to apply validations only to a subset of rows.\n\nThis is useful when you want to validate specific business segments, statuses, partitions, or recent data.\n\nExample:\n\n```yaml\nmodels:\n  - name: orders\n    columns:\n      - name: value\n        data_tests:\n          - dbt_checks.greater_than:\n              arguments:\n                value: 0\n                where: \"status = 'active'\"\n```\n\nThe `where` expression is applied before the check runs.\n\n# Standardized Failure Output\n\ndbt-checks provides standardized and human-readable failure outputs designed for easier debugging and CI visibility.\n\nInstead of generic outputs like:\n\n```text\nGot 1 result, configured to fail if != 0\n```\n\nchecks now expose contextual failure information.\n\n## Row-level checks\n\nExample output:\n\n| failing_value | expected_min_value | failed_check | failure_reason |\n| --- | --- | --- | --- |\n| -5 | 0 | non_negative | Value must be greater than or equal to 0 |\n\nUsed by:\n- numeric checks\n- string checks\n- most temporal checks\n\n---\n\n## Aggregation checks\n\nExample output:\n\n| actual_value | expected_min_value | expected_max_value |\n| --- | --- | --- |\n| 1500 | 0 | 1000 |\n\nUsed by:\n- avg_between\n- sum_between\n- min_between\n- max_between\n- row_count_between\n\n---\n\n## Ratio checks\n\nExample output:\n\n| actual_ratio | expected_min_ratio | expected_max_ratio |\n| --- | --- | --- |\n| 0.92 | 0.0 | 0.80 |\n\nUsed by:\n- null_ratio_between\n- positive_ratio_between\n- negative_ratio_between\n- value_ratio_between\n\n---\n\n## Additional Context\n\nChecks may also expose:\n\n- `failed_check`\n- `failure_reason`\n- `applied_condition`\n- `actual_length`\n- `actual_diff_days`\n- `actual_day_of_week`\n\nThis makes dbt-checks outputs easier to:\n- debug in CI\n- inspect in stored failures\n- integrate with observability tooling\n- consume programmatically\n\n# NULL Handling\n\ndbt-checks follows a consistent and explicit null-handling strategy.\n\nMost checks ignore null values by default.\nUse dedicated checks to validate null presence.\n\n## Summary:\n\n- Numeric        → ignored  \n- String         → ignored  \n- Temporal       → ignored  \n- Aggregation    → ignored (SQL behavior)  \n- Row count      → includes nulls  \n- Ratio checks   → explicit handling  \n\nUse:\n- null_ratio_below\n- null_ratio_between\n\n# Available Checks\n\ndbt-checks provides reusable data validation tests grouped by category.\n\n## Numeric\n\nNumeric checks validate numeric ranges and thresholds.\n\nCheck | Description\n----- | ----------\n`non_negative` | Ensures values are ≥ 0\n`non_positive` | Ensures values are ≤ 0\n`greater_than` | Ensures values are greater than a threshold\n`greater_or_equal_than` | Ensures values are ≥ a threshold\n`less_than` | Ensures values are less than a threshold\n`less_or_equal_than` | Ensures values are ≤ a threshold\n`between_values` | Ensures values fall within a numeric range\n\nExample\n\n``` yaml\ncolumns:\n  - name: value\n    data_tests:\n      - dbt_checks.between_values:\n          arguments:\n            min_value: 0\n            max_value: 100\n```\n## String\n\nString checks validate textual fields such as identifiers or formatted values.\n\nCheck | Description\n----- | ----------\n`not_blank` | Ensures strings are not empty or whitespace\n`length_between` | Validates string length range\n`matches_regex` | Validates a regex pattern\n`starts_with` | Ensures string starts with prefix\n`ends_with` | Ensures string ends with suffix\n`contains` | Ensures string contains substring\n\nExample\n\n``` yaml\ncolumns:\n  - name: email\n    data_tests:\n      - dbt_checks.matches_regex:\n          arguments:\n            pattern: \"^[^@]+@[^@]+\\\\.[^@]+$\"\n```\n## Temporal\n\nTemporal checks validate date and timestamp fields.\n\nCheck | Description\n----- | ----------\n`not_future_date` | Ensures date is not in the future\n`not_before_date` | Ensures date is after a minimum date\n`between_dates` | Ensures date is within a range\n`recent_date` | Ensures date is within N days\n`date_diff_less_than` | Ensures difference between two dates is within threshold\n`no_weekend_dates` | Ensures dates do not fall on weekends\n\nExample\n\n``` yaml\ncolumns:\n  - name: date\n    data_tests:\n      - dbt_checks.recent_date:\n          arguments:\n            max_age_days: 7\n```\n## Aggregation\n\nAggregation checks validate dataset-level metrics.\nNulls follow SQL behavior (ignored in aggregation).\n\nCheck | Description\n----- | ----------\n`row_count_greater_than` | Ensures model has at least N rows\n`row_count_less_than` | Ensures model has at most N rows\n`row_count_between` | Ensures row count falls within range\n`sum_between` | Ensures column sum falls within range\n`avg_between` | Ensures column average falls within range\n`max_between` | Ensures column maximum falls within range\n`min_between` | Ensures column minimum falls within range\n\n**If all values are null → test fails**\n\nExample\n\n``` yaml\nmodels:\n  - name: orders\n    data_tests:\n      - dbt_checks.row_count_greater_than:\n          arguments:\n            value: 100\n```\n## Ratio\n\nRatio checks validate proportions of rows matching a condition.\n\nCheck | Description\n----- | ----------\n`null_ratio_below` | Ensures null ratio is below threshold\n`null_ratio_between` | Ensures null ratio is within range\n`positive_ratio_between` | Ensures positive value ratio within range\n`negative_ratio_between` | Ensures negative value ratio within range\n`value_ratio_between` | Ensures specific value ratio within range\n\n**Null handling:**\n- null_ratio_* explicitly evaluates nulls\n- others use total row count as denominator\n\nExample\n\n``` yaml\ncolumns:\n  - name: email\n    data_tests:\n      - dbt_checks.null_ratio_below:\n          arguments:\n            threshold: 0.05\n```\n# Supported Warehouses\n\n`dbt-checks` is designed to work across common dbt adapters:\n\n-   Snowflake\n-   BigQuery\n-   Databricks\n-   Spark\n-   Redshift\n-   Postgres\n\nAdapter-specific behavior is handled through dbt's `dispatch` mechanism.\n\n**Tested on DuckDB in CI.**\n\n**Aditional adapters are supported through dbt dispatch (best-efort compatibility).**\n\n# Why dbt-checks?\n\nMany dbt projects repeatedly implement the same validation logic.\n\n`dbt-checks` provides:\n\n- reusable checks\n- simple configuration\n- scoped checks with optional `where` filters\n- standardized failure outputs\n- CI-friendly debugging context\n- predictable null handling\n- consistent validation patterns\n- cross-warehouse compatibility\n- reusable internal helper architecture\n- consistent SQL generation across checks\n- centralized casting, predicates, ratios, and filtering logic\n\n# Internal Architecture\n\n`dbt-checks` uses reusable internal helper macros to standardize SQL generation across all checks.\n\nInternal helpers include:\n\n- casting helpers\n- reusable predicates\n- ratio utilities\n- filter application helpers\n- date utilities\n- validation helpers\n\nThis improves:\n- maintainability\n- adapter compatibility\n- consistency\n- future extensibility\n\n# Contributing\n\nContributions are welcome.\n\nTo add a new check:\n\n1.  Implement it in `macros/tests`\n2.  Reuse helper macros when possible\n3.  Add documentation\n4.  Add integration tests (including null behavior)\n\n# License\n\nThis project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllucmh%2Fdbt-checks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fllucmh%2Fdbt-checks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllucmh%2Fdbt-checks/lists"}