Declarative Data Tests are automated quality validation rules defined in a high-level, configuration-based language (e.g., YAML, SQL) that specify expected data conditions—such as uniqueness, freshness, or referential integrity—without detailing the procedural steps for checking them. This approach separates the 'what' (the business logic) from the 'how' (the execution engine), enabling data engineers to define constraints like column_X must be non-null in a portable, version-controlled file. The underlying Data Quality Rule Engine then interprets and executes these statements, making validation scalable and maintainable across complex pipelines.
Glossary
Declarative Data Tests

What is Declarative Data Tests?
A core methodology for ensuring data integrity through configuration-driven validation.
This paradigm is foundational to modern Data Observability Platforms and practices like Data Monitoring as Code, where tests are treated as declarative infrastructure. By codifying expectations for schema, statistical distribution, and custom business rules, teams establish Data Quality Gates that prevent faulty data from propagating. This shifts data validation from ad-hoc scripting to a systematic engineering discipline, directly supporting Data Reliability Engineering (DRE) objectives and enabling automated enforcement of Data Contracts between producers and consumers.
Key Characteristics of Declarative Data Tests
Declarative Data Tests define validation rules in a high-level configuration language, specifying what data conditions must be true without detailing how to check them. This approach enables scalable, maintainable, and portable data quality assurance.
Configuration-Driven Definition
Tests are defined as configuration artifacts (e.g., YAML, JSON, SQL snippets) rather than imperative code. This separates the validation logic from the execution engine, enabling:
- Portability: The same test definition can be executed across different runtime environments (Spark, Snowflake, BigQuery).
- Version Control: Test logic is stored in Git, enabling code review, rollback, and audit trails.
- Centralized Management: A single source of truth for all data quality rules across an organization.
Separation of Logic and Execution
The declarative model enforces a clean separation between the what (the validation rule) and the how (the execution engine). The test author specifies the expected condition (e.g., column X must be unique), and the underlying Data Quality Rule Engine determines the optimal execution path. This abstraction:
- Simplifies authoring for data practitioners who understand business logic but not distributed computing.
- Enables engine optimization, as the platform can choose the most efficient query or algorithm.
- Facilitates tool agnosticism, allowing organizations to switch execution backends without rewriting tests.
Composable and Reusable Rules
Declarative tests are built from atomic, reusable components. Common patterns include:
- Schema Validations: Checks for data type, nullability, and allowed values.
- Freshness Checks: Ensures data is updated within a specified time window.
- Volume Anomalies: Detects unexpected spikes or drops in row counts.
- Custom SQL Assertions: Allows for complex business logic validation. These components can be composed into test suites applied to multiple tables or datasets, ensuring consistent quality standards. Changes to a base rule propagate automatically to all dependent tests.
Integration with CI/CD and Data Pipelines
Declarative tests are designed to be executed as automated checkpoints within modern data workflows:
- CI/CD for Data: Tests run automatically in pre-merge checks for schema changes or new data pipeline code.
- Data Quality Gates: Tests act as gates in orchestration tools (e.g., Airflow, Dagster), preventing downstream processes from consuming invalid data.
- Shift-Left Testing: Quality rules are applied to development and staging environments, catching issues before they reach production. This practice is foundational to Data Reliability Engineering (DRE).
Declarative vs. Imperative Testing
This contrasts with imperative data testing, where validation logic is written as procedural code (e.g., Python scripts with explicit loops and conditionals).
Declarative (YAML Example):
yamltest_type: uniqueness table: orders columns: [order_id]
Imperative (Python Pseudocode):
pythondef test_uniqueness(): df = spark.table('orders') duplicate_count = df.groupBy('order_id').count().filter('count > 1').count() assert duplicate_count == 0
The declarative approach is more concise, less error-prone, and easier for non-engineers to audit and modify.
Core Quality Dimensions Addressed
Declarative tests are used to enforce key dimensions of the Data Health Score:
- Accuracy: Data correctly reflects the real-world entity it represents (e.g.,
price > 0). - Completeness: Mandatory fields are populated (e.g.,
customer_id IS NOT NULL). - Consistency: Data conforms to uniform formats and units across systems.
- Timeliness/Freshness: Data is available within an expected timeframe (e.g.,
max(timestamp) >= NOW() - INTERVAL '1 hour'). - Uniqueness: No unintended duplicate records exist.
- Validity: Data adheres to defined business rules and domain constraints.
How Declarative Data Tests Work
Declarative Data Tests are a core component of modern data observability, enabling automated quality validation through configuration rather than custom scripting.
Declarative Data Tests are quality validation rules defined in a high-level, configuration-based language (e.g., YAML, SQL) that specify what conditions data must meet—such as uniqueness, freshness, or referential integrity—without detailing the how of the procedural verification steps. This abstraction separates the business logic of data quality from the underlying execution engine, allowing data engineers to define rules like column_X must be non-null in a portable, version-controlled format. The data quality rule engine then interprets these declarations, executes the necessary queries or checks against the target dataset, and produces a pass/fail result, often integrated into a CI/CD for Data pipeline or a data quality gate.
The operational workflow begins when a data observability platform or scheduler triggers the test suite, typically after a data pipeline execution. The engine parses the declarative rules, which may include statistical checks (e.g., mean value within range), schema validations, or custom SQL assertions. It executes these checks efficiently, often leveraging metadata and automated data profiling to optimize queries. Results are logged, and failures generate alerts routed through a data incident triage workflow. This model promotes scalability, reusability, and clear ownership, as the intent of each test is explicitly documented in the configuration, making data quality a transparent, engineering-managed concern rather than an opaque, script-heavy process.
Declarative vs. Imperative Data Testing
A comparison of the two primary programming paradigms for defining data quality validation rules, focusing on their core characteristics and operational impact within data observability platforms.
| Feature / Characteristic | Declarative Data Tests | Imperative Data Tests |
|---|---|---|
Definition | Specifies what the expected data condition is (the goal) without detailing the procedural steps. | Specifies how to perform the validation through explicit, step-by-step control flow and logic. |
Primary Abstraction | Configuration (e.g., YAML, JSON, domain-specific language). | General-purpose programming code (e.g., Python, Java, SQL scripts). |
Implementation Example |
| A Python function with loops, conditionals, and custom exception handling to check uniqueness or value ranges. |
Test Logic Location | Encapsulated within the testing framework/engine. Logic is interpreted from config. | Explicitly written by the developer within the test code itself. |
Code Volume & Complexity | Low. Typically 1-5 lines per test rule. | High. Can be tens to hundreds of lines for complex business logic. |
Maintainability & Readability | High. Intent is clear and separate from execution mechanics. Easier to review and audit. | Variable. Depends heavily on code quality and documentation. Logic is intertwined with control flow. |
Portability & Reusability | High. Declarative rules are often engine-agnostic and can be shared across pipelines and teams. | Low. Tightly coupled to the specific execution environment and codebase. |
Execution Control | Managed by the framework. Optimizations (e.g., parallel execution, query push-down) are handled automatically. | Controlled by the developer. Requires manual optimization for performance and resource management. |
Integration with CI/CD & Orchestrators | Seamless. Config files are easily versioned and integrated as pipeline dependencies. | Possible but more complex. Requires managing and deploying code artifacts and their dependencies. |
Learning Curve for Data Practitioners | Low. Accessible to data analysts, engineers, and stewards with domain knowledge. | High. Requires software engineering skills and knowledge of the specific programming ecosystem. |
Flexibility for Edge Cases | Moderate. Limited by the expressiveness of the declarative language. May require custom SQL snippets. | Very High. Can implement any arbitrarily complex validation logic the language supports. |
Typical Performance Profile | Optimized by the engine. Often translates to efficient single-pass SQL queries over the dataset. | Determined by the developer's code. Can be inefficient without careful optimization (e.g., N+1 query problems). |
Primary Use Case | Standard data quality dimensions: nullness, uniqueness, referential integrity, freshness, distributional checks. | Complex, multi-step business logic validation, data reconciliation across systems, and custom anomaly detection. |
Common Examples of Declarative Data Tests
Declarative data tests define expected data conditions using configuration files (e.g., YAML, SQL). These are the most common patterns used to enforce data quality and business logic.
Schema and Type Validation
Ensures data adheres to expected structural formats and data types. This foundational test prevents downstream errors caused by malformed data.
- Column Existence: Verifies a required column is present in a table.
- Data Type Conformance: Checks that values in a column (e.g.,
customer_id) match the declared type (e.g.,INTEGER,TIMESTAMP). - Nullability Constraints: Enforces whether a column can contain
NULLvalues.
Example YAML rule: assert_column_exists: table: orders, column: order_id
Freshness and Latency Checks
Monitors the timeliness of data updates to ensure information is current and meets Service Level Objectives (SLOs) for delivery.
- Maximum Allowable Delay: Asserts that the most recent record in a table is no older than a threshold (e.g.,
updated_at >= NOW() - INTERVAL '1 hour'). - Ingestion Heartbeat: Validates that a pipeline has successfully written data within a scheduled window.
These tests are critical for time-sensitive use cases like dashboards and real-time analytics, directly impacting data downtime metrics.
Volume and Completeness Tests
Validates that data arrives in expected quantities and is not missing critical segments.
- Row Count Boundaries: Declares that a table should have between an expected minimum and maximum number of rows after a refresh (e.g.,
row_count between 1000 and 5000). - Non-Null Completeness: Ensures a critical column has no missing values (e.g.,
non_null_count(email) = total_row_count). - Uniqueness: Asserts that values in a key column are distinct (e.g.,
unique_count(order_id) = total_row_count).
These tests catch pipeline breaks, incomplete loads, and duplicate generation issues.
Referential Integrity Tests
Enforces consistency and valid relationships between different datasets, a core principle of data reliability engineering.
- Foreign Key Validity: Verifies that all values in a child table's column (e.g.,
orders.customer_id) exist in the parent table (customers.id). - Orphan Record Detection: Identifies records in a reference table that are no longer linked to any primary record.
Declarative SQL example: SELECT COUNT(*) FROM orders o LEFT JOIN customers c ON o.customer_id = c.id WHERE c.id IS NULL must equal 0.
Statistical Distribution Tests
Uses statistical methods to validate that data values fall within expected numerical ranges and distributions, often leveraging dynamic baselines.
- Value Range: Asserts that a numeric column's values (e.g.,
transaction_amount) stay within a sane min/max (e.g.,0 <= value <= 1000000). - Average/Median Stability: Checks that aggregate metrics do not deviate beyond a percentage threshold from a rolling historical average.
- Standard Deviation Bound: Flags if the dispersion of a column's values exceeds an expected limit, which can indicate data corruption.
These tests are proactive guards against data drift and subtle quality degradation.
Custom Business Logic Validation
Encodes domain-specific rules that data must satisfy to be considered accurate for business operations.
- Calculated Field Accuracy: Validates that a derived column (e.g.,
total_price) correctly equalsunit_price * quantity - discountfor all rows. - State Transition Validity: Ensures status fields follow a permitted sequence (e.g., an order cannot move from
shippedback topending). - Cross-Table Consistency: Asserts that aggregated metrics in a summary table match the sum of granular records in a source table.
These declarative rules move critical business knowledge out of application code and into observable, version-controlled data monitoring as code.
Frequently Asked Questions
Declarative Data Tests are a core component of modern data observability, enabling automated quality validation through configuration rather than procedural code. This FAQ addresses common questions about their implementation, benefits, and role in a data quality posture.
A Declarative Data Test is a quality validation rule defined in a high-level, configuration-based language (e.g., YAML, SQL) that specifies the expected state or condition of data without detailing the procedural steps for checking it. The system's execution engine interprets the declaration to perform the validation. This contrasts with imperative testing, where the exact sequence of operations is manually coded. For example, a declarative test for a customers table might be written as column: id, test: unique or as a SQL assertion like SELECT COUNT(*) FROM customers HAVING COUNT(*) = COUNT(DISTINCT email). The test declares what the data condition should be (e.g., uniqueness, non-null, referential integrity), not how to verify it.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Declarative Data Tests are a core component of a modern data quality posture. They integrate with several related concepts and tools that define, enforce, and monitor data reliability.
Data Quality Rule Engine
A Data Quality Rule Engine is the software component that executes the logic defined in Declarative Data Tests. It parses the high-level configuration (e.g., YAML, SQL), translates it into executable validation code, runs the checks against the target data, and produces pass/fail results. This engine is the runtime that brings declarative tests to life, often integrated directly into data pipelines or orchestration tools.
Data Monitoring as Code
Data Monitoring as Code is the overarching practice that Declarative Data Tests exemplify. It involves defining all data quality checks, observability rules, and alerting logic in version-controlled, machine-readable configuration files (like YAML). This enables:
- Versioning and peer review of quality rules.
- Automated deployment of monitoring alongside pipeline code.
- Consistency and reproducibility across development, staging, and production environments.
- Infrastructure-as-Code (IaC) principles applied to data reliability.
CI/CD for Data
CI/CD for Data is the pipeline automation framework into which Declarative Data Tests are integrated. It applies software engineering's Continuous Integration and Continuous Delivery practices to data assets. Declarative tests act as quality gates within this pipeline:
- Continuous Integration: Tests run automatically when new data pipeline code or schema definitions are committed.
- Continuous Delivery: Tests validate data quality in staging environments before promoting datasets to production.
- Rollback Triggers: Failed tests can automatically prevent faulty data from being published or trigger rollbacks.
Data Quality Gate
A Data Quality Gate is a specific checkpoint, often enforced by Declarative Data Tests, that blocks the progression of a data pipeline unless validation rules are satisfied. It is the practical implementation of a test in a workflow. For example:
- A gate after a raw data ingestion job that checks for
NOT NULLconstraints on key columns. - A gate before a BI dashboard updates that validates row counts are within expected bounds.
- Gates ensure that only data meeting a defined quality threshold proceeds to downstream consumers, preventing "bad data" from propagating.
Data Contract Monitoring
Data Contract Monitoring uses Declarative Data Tests as its enforcement mechanism. A data contract is a formal agreement between a data producer and consumer specifying schema, semantics, freshness, and quality guarantees. Declarative tests codify these guarantees:
- Schema Validation: Tests enforce column names, data types, and allowed values.
- Semantic Rules: Tests validate business logic (e.g.,
revenue = quantity * price). - SLI/SLO Compliance: Tests measure indicators like freshness or completeness against agreed objectives.
- Automated monitoring of these tests ensures contractual compliance is continuously verified.
Automated Data Profiling
Automated Data Profiling is a complementary discovery process that often informs the creation of Declarative Data Tests. Profiling tools automatically analyze a dataset to infer its structure, statistics, and patterns. The outputs—such as discovered distributions, uniqueness, and null rates—provide the empirical basis for writing meaningful declarative rules. For instance, profiling might reveal that a customer_id column is 100% unique, leading to the creation of a declarative test asserting column_is_unique(customer_id).

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us