Editor’s introduction
The study evaluates PrismaDV, an AI system that generates data unit tests by examining both dataset profiles and the code that consumes them. It identifies data access patterns and implicit assumptions, producing tests that align with specific downstream tasks. The study also introduces SIFTA, a prompt-optimization framework that adapts test generation based on execution outcomes. Performance gains are observed when SIFTA refines prompts through selective feedback from test failures.
Introduction
Data is a central resource for modern enterprises and institutions, and data issues, such as missing or incorrect information, can seriously impact their operations. Data errors propagating through data systems lead to serious impact in production, such as outages of mobile apps, bank customers losing access to their accounts, outages of flights in the US, and the loss of medical records. Furthermore, data errors are one of the major reasons for the silent performance degradation of deployed ML models. A reason for this is that many organizations have adopted a “collect first, analyze later” workflow, relying on the schema-on-read interpretation of data in downstream applications. Therefore, corrupted data often propagates unnoticed until it causes failures in production.
Current landscape of data unit testing frameworks. As a consequence, data unit testing frameworks such as TensorFlow Data Validation, Amazon’s Deequ, and Great Expectations have become widely used in industry in recent years. These frameworks generate data unit tests: declarative data constraints, often expressed in an easy-to-use DSL, such as null-value checks, completeness and uniqueness constraints, value-range checks, and distributional sanity checks. These constraints are inferred by profiling a data sample and subsequently applying heuristics, against which to validate unseen data. Major cloud providers offer data unit testing as part of their data infrastructure: Amazon’s AWS Glue Data quality service defines a domain-specific language to enable non-coders to define data unit tests with Deequ, Databricks allows its users to annotate data pipelines with “pipeline expectations” for data unit testing, Google Dataplex enables customers to choose from auto-suggested data quality rules for catching data anomalies in their data pipelines, and GXCloud recently announced an AI-driven constraint suggestion feature.
Background
We briefly introduce the required background on data unit tests. Data unit tests are typically deployed as part of data pipelines which move data between different systems and applications. The goal of a data unit test is to flag potentially erroneous data early to allow engineers to intervene before the data already caused issues in downstream applications. Data unit tests are crucial for the data operations in large organizations, where data updates are regularly produced and consumed by hundreds of downstream applications.
Designing data unit tests is challenging since it requires intricate knowledge about invariants of the data and the domain in which it is used. Furthermore, there is a tension between overly strict constraints, which may produce many false alarms and too general constraints, which may not be helpful in identifying issues in the data. Popular libraries like Deequ and Tensorflow Data Validation offer automated ways to suggest constraints based on data profiling, which must typically be post-edited by data engineers.
Problem Statement
The need for the automated generation of task-aware data unit tests. The examples show that a single central data unit test, derived from the data, is insufficient to adequately address potential data issues that can occur. Instead, an intricate understanding of the code and data assumptions of the downstream tasks are required. Ideally, a custom test for each downstream task, tailored to its specific data assumptions and access pattern is deployed. This would be to avoid both false alarms (which cause unnecessary work for devops engineers and on-call sessions on the weekend) and missed data issues (which may crash downstream services). However, creating specialized data unit tests is very tedious since popular datasets in large data lakes maybe consumed by hundreds of downstream services, often with hard-to-understand codebases (e.g., legacy code). Furthermore, both data and downstream services continuously change and evolve in large organizations, requiring a regular adjustment of the data unit tests.
Research question. This leads us to the research question in the focus of this paper: Can we automate the generation of data unit tests, such that they are tailored to downstream code? Our goal is to change the development of data unit tests from its reactive nature (adjusting tests after production incidents) to a proactive nature, where comprehensive tests are generated upfront. At the same time, we aim to alleviate the need for domain experts to write custom data unit tests. An automated system should leverage task code in addition to sample data to design, specialize and improve tests, by uncovering and including the hidden domain knowledge and data assumptions in the code.
Optimization via Selective Informative Feedback for Task Adaptation (SIFTA)
In real-world deployments, data validation runs as part of data pipelines that continuously ingest new data batches. Over time, teams accumulate execution outcomes that indicate whether a task run succeeded or failed on specific batches. These observations are scarce, but they provide feedback for improving validation quality on future data. Moreover, multiple tasks often consume the same input dataset. They can share latent data assumptions or business logic, such as preprocessing steps, joins, or feature engineering. This creates transfer opportunities: outcomes from existing tasks and batches can help improve validation for new batches and tasks.
Taken together, these properties motivate an optimization approach for task-aware data unit tests generation. Since PrismaDV is a compound AI system with LLM-based modules, there are several optimization choices such as updating LLM parameters, e.g., via reinforcement learning or fine-tuning or adjusting prompts of the LLM-based modules. In production settings, however, updating LLM parameters for each new task is often infeasible, as it incurs significant training cost, fine-tuning parameter storage, and deployment and versioning overhead. We therefore focus on prompt optimization for PrismaDV’s LLM-based modules, as it requires no model training, fits within existing inference pipelines, and can be driven by the scarce execution outcomes collected in production.
Optimization Setting
Scarce and delayed supervision. The primary feedback available in practice is a binary execution outcome for a task run on a data batch. Obtaining more specific supervision signals (e.g., which column caused a failure or which assumption was violated) is difficult and expensive, and may require substantial debugging. This issue is exacerbated in ML pipelines, where the manifestation of data issues can be delayed (e.g., gradual performance degradation), making it hard to collect fine-grained error feedback at scale.
Multiple intermediate trajectories with localized errors. Task-aware validation generates rich intermediate artifacts (e.g., column access patterns, assumption summaries, constraint candidates, and code), which can be long and heterogeneous. At the same time, data issues in a batch are typically localized to a small subset of columns or interactions. This mismatch makes it hard to directly apply existing prompt-optimization methods (e.g., MIPROv2, GEPA ), which are commonly evaluated in settings with smaller trajectories and more dense feedback.
Optimization Procedure
Based on the analysis above, we introduce Selective Informative Feedback for Task Adaptation (SIFTA), a lightweight prompt-optimization procedure that leverages informative failure signals captured by failure precision. SIFTA concentrates optimization on task–column units with constraint failures and backtraces failing constraints to the assumptions and code locations that produced them, providing targeted feedback for prompt updates.
Implementation. We implement SIFTA using DSPy’s prompt-optimization API. In our pipeline, the prompts for dataflow analysis, assumption inference, and constraint code generation are tightly coupled through shared intermediate artifacts. As a result, updating only one module prompt can create contextual mismatches across modules. SIFTA therefore uses a global prompt proposer that can jointly update one or multiple module prompts within a single proposal. Each proposal is conditioned on a shared instruction prompt that provides task-aware data validation context and motivates failure precision as the proxy optimization target.
ICDBench – Individual Constraint Discovery from Data-Code Pairs
The building block of a task-aware data unit test generation system is the ability to discover constraints about the data which are implicitly defined in code. To evaluate this ability (independent of the other end-to-end building blocks of the system), we design ICDBench, a novel benchmark for constraint discovery from data-code pairs. This benchmark includes 63 cases, each of which consists of a tabular data sample, a piece of code written to process the data, a natural language description of the hidden assumption in the code, and the corresponding ground truth constraint in PyDeequ syntax. Furthermore, each case features two held-out pieces of data: a positive example of data to pass (on which the constraint holds), and a negative example of data to reject, where the constraint is not satisfied. ICDBench includes hand-designed cases as well as a large number of data-code pairs obtained from public GitHub repositories. We explicitly design it to include a diverse range of hidden assumptions in code, ranging from simple cases like explicit asserts, to tough cases like column dependencies expressed in control flow or knowledge about semantics in ML libraries (e.g., scikit-learn operations). Moreover, the benchmark covers a wide range of domains, including payment processing, cricket sports rules, and in-game auctions in video games.
EIDBench – End-to-End Error Impact Detection
Downstream tasks. A core challenge in building an end-to-end benchmark is obtaining diverse, executable downstream tasks for the same tabular dataset: such code is common in industry but rarely shared with the academic community, while public notebooks, like the ones from Kaggle, often follow repetitive EDA/model-training templates. We therefore synthesize downstream tasks and their ground-truth assumptions using an LLM-assisted, human-in-the-loop pipeline.
Assertion blocks and leakage control. Each assertion block is delimited by sentinel comments (e.g., # ASSERTION_START / # ASSERTION_END) to enable programmatic removal and reinsertion. We use the blocks in two ways: (i) for inference, we remove all assertion blocks and provide the resulting code to the system under test, preventing trivial extraction of assumptions from explicit asserts; (ii) for labeling, we execute the script with assertion blocks enabled on evaluation batches. A data batch is labeled erroneous for a task if its execution crashes or any assertion fails; otherwise it is labeled safe. To prevent leakage, we ensure that removing assertion blocks leaves the task executable and that no program state used by the core task is defined or modified inside assertion blocks. In addition, we manually review each task’s code to remove bugs and eliminate assumption leakage via comments or task logic.
Related Work
Data validation. Existing data validation systems vary in how rules are specified and inferred. Great Expectations offers a flexible assertion grammar but relies on manually defined expectation suites, limiting automation. Deequ and TFDV infer statistical constraints via data profiling, while Auto-Test and Auto-Validate learn semantic constraints from large table corpora, with Auto-Validate focusing on string columns. These approaches are largely task-agnostic and depend primarily on observed data. DataPrism incorporates downstream systems, using causal reasoning to identify data-profile violations that trigger failures. In contrast, PrismaDV generates task-aware validation rules across heterogeneous columns by jointly reasoning over data and code, capturing both explicit violations and latent data issues that induce abnormal program behavior.
Code understanding with LLMs. PrismaDV’s performance in extracting data assumptions depends on the code understanding capabilities of LLMs. Recent studies have demonstrated that LLMs can reason about code execution behavior and program semantics. LLMDFA further shows that LLMs can serve as effective tools for performing data-flow analysis over source code, and RepoAudit leverages such reasoning for repository-level auditing. Multiple benchmarks evaluate LLM code understanding and reasoning abilities. However, none of these benchmarks explicitly target implicit data assumptions embedded in code, which our ICDBench and EIDBench capture (Section 6).
Constraint Discovery from Data-Code Pairs
A first observation is that the outlier detection based approaches exhibit an extremely low performance. This is a validation of our benchmark design, since it shows that inspecting data alone is not sufficient to make correct decisions, but that an “understanding” of the code is required. The task-agnostic data unit tests, LLM prompting approaches and software engineering agents provide a mixed performance with the largest F1 scores in the high sixties (deequ with a score of 61.5%, few-shot [gpt-5] with a score of 66.7%, and swe-agent with a score of 65.4%). We observe that prompting approaches and agentic systems often generate the correct ground truth constraint, but suffer from the fact that they generate additional constraints which do not hold on the data. Our system PrismaDV manages to outperform them all by a large margin of more than 20 points with an F1-score 87.8% for prismaDV [gpt-5]. Furthermore, it provides the lowest number of mispredictions, which is an important metric for operational deployments, where a misprediction might lead to a data engineer having to inspect the data manually to no avail. In summary, these findings confirm that constraint discovery from code is a difficult task, which benefits from a dedicated system and cannot be sufficiently solved with prompting or general engineering agents alone. Beyond the F1 margin, PrismaDV’s step-wise decomposition makes each stage easier to inspect.
End-To-End Error Impact
Zero-shot and few-shot baselines perform substantially worse than PrismaDV. They show a strong tendency to generate more false alarms than misses, which is reflected in the gap between precision and recall. This suggests that these models generate overly strict constraints. With our post-processing, all constraints generated by PrismaDV in the testing stage are executable. Across different backend LLMs, PrismaDV achieves consistent performance, with prismaDV [gpt-5] reaching the highest F1 score of 77.4%. At the same time, different backbone LLMs exhibit different trade-offs between missed rejections and false alarms. For example, prismaDV [gpt-5] raises relatively few false alarms (112), but it misses many erroneous cases (305). In contrast, prismaDV [gemini-2.5-pro] misses very few erroneous cases (195), but it raises more false alarms (230). This highlights that PrismaDV’s preference depends on the backbone LLM, and practitioners can choose a model based on their tolerance for false alarms versus missed rejections.
Optimizing PrismaDV with SIFTA
GEPA[P], GEPA[S], and SIFTA are all assigned a budget of 15 full evaluation executions, which is more than enough for the optimization process to converge. For SIFTA, we recalculate the training set condensation stage every 5 full evaluation executions. We repeat the experiment with two different random seeds, and set the training sample batch size to three for both methods. We use gpt-5 as the prompt proposer and gpt-4.1-mini as the backbone LLM of the data validation system for both methods.
Conclusion
This paper introduced PrismaDV, a task-aware data validation approach that synthesizes specialized data unit tests based on both the data and downstream tasks. To improve PrismaDV’s performance on specific datasets, we further proposed SIFTA, an optimizer that efficiently adapts the prompts used in PrismaDV’s modules based on failure precision on training examples. To evaluate task-aware data validation systems from diverse perspectives, we introduced two novel benchmarks, ICDBench and EIDBench.
Limitations and Future Work. Our prototype focuses on single-file tasks over a single table. Supporting multi-file code and multi-table inputs will require additional engineering, such as tracking dataflow across scripts and reasoning about joins and derived tables, but remains conceptually compatible with task-aware assumption inference. A promising next step is to extend our benchmarks with real industry workloads, enabling evaluation under more realistic codebases, data distributions, and operational constraints. By treating textual data assumptions as an intermediate representation, PrismaDV has the potential to support multiple validation DSLs, such as Great Expectations and Python assert statements. SIFTA currently relies on training batches with observed errors, which can be difficult to obtain in practice. Automating error injection could synthetically generate training batches, enabling optimization without relying on naturally occurring failures and making PrismaDV more suitable for cold-start settings. In SIFTA, we adopted a simple greedy search strategy, we leave evaluating more advanced strategies (e.g., Monte Carlo tree search) for future work.


