  Data-driven applications rely on the correctness of their data to function
properly and effectively. Errors in data can be incredibly costly and
disruptive, leading to loss of revenue, incorrect conclusions, and misguided
policy decisions. While data cleaning tools can purge datasets of many errors
before the data is used, applications and users interacting with the data can
introduce new errors. Subsequent valid updates can obscure these errors and
propagate them through the dataset causing more discrepancies. Even when some
of these discrepancies are discovered, they are often corrected superficially,
on a case-by-case basis, further obscuring the true underlying cause, and
making detection of the remaining errors harder. In this paper, we propose
QFix, a framework that derives explanations and repairs for discrepancies in
relational data, by analyzing the effect of queries that operated on the data
and identifying potential mistakes in those queries. QFix is flexible, handling
scenarios where only a subset of the true discrepancies is known, and robust to
different types of update workloads. We make four important contributions: (a)
we formalize the problem of diagnosing the causes of data errors based on the
queries that operated on and introduced errors to a dataset; (b) we develop
exact methods for deriving diagnoses and fixes for identified errors using
state-of-the-art tools; (c) we present several optimization techniques that
improve our basic approach without compromising accuracy, and (d) we leverage a
tradeoff between accuracy and performance to scale diagnosis to large datasets
and query logs, while achieving near-optimal results. We demonstrate the
effectiveness of QFix through extensive evaluation over benchmark and synthetic
data.
