Abstract
Query repair involves automatically adjusting filter predicates to satisfy high-level aggregate constraints (ACs), such as fairness or budget limits. This paper introduces a novel framework that utilizes kd-tree data partitioning and interval arithmetic to prune the search space for optimal repairs. The proposed Cluster Range Pruning (RP) algorithm achieves order-of-magnitude speedups compared to brute-force approaches while preserving the original query's intent.
Introduction
Data analysts frequently write queries to select candidates for critical processes like hiring, loan approvals, or school admissions. However, the resulting datasets often violate domain-specific requirements—for instance, a selection rate might be biased against a specific demographic, or a total project cost might exceed a budget. Manually fixing these queries is challenging because aggregate constraints (ACs) are often non-monotone: a simple change to a filter (e.g., lowering a GPA threshold) does not always lead to a predictable change in the final aggregate score.
Existing query repair tools typically handle only simple cardinality constraints. This research addresses the more complex problem of repairing queries against arithmetic combinations of aggregates, ensuring that the modified query remains as close as possible to the user's original intent.
Methodology
The authors propose a framework based on data partitioning and hierarchical statistics. The process begins by partitioning the input data into a kd-tree based on the attributes used in query filters. For every node (cluster) in this tree, aggregate statistics such as count, sum, minimum, and maximum are pre-calculated and materialized.
Full Cluster Filtering (FF)
The FF algorithm optimizes the evaluation of individual repair candidates. By traversing the kd-tree, the system can determine if a cluster's data bounds are entirely within or outside a filter's range. If so, the materialized aggregates are used immediately, bypassing the need to scan individual rows and significantly reducing I/O overhead.
Cluster Range Pruning (RP)
The RP algorithm introduces interval arithmetic to evaluate sets of candidates simultaneously. Instead of checking one constant at a time, RP calculates the lower and upper possible bounds of an aggregate constraint for an entire interval of potential constants. If the entire range of possible results for a set of candidates violates the constraint, the whole set is pruned from the search space. Conversely, if the entire range satisfies the constraint, all candidates in that set are confirmed as valid.
Experimental Evaluation
The framework was evaluated using three diverse datasets: the Adult Census Income dataset (fairness constraints), a Healthcare dataset (demographic balance), and the TPC-H industry benchmark (budget and business logic).
Key findings include:
- Performance: The RP algorithm consistently outperformed brute-force methods by at least one order of magnitude (10x).
- Pruning Efficiency: RP dramatically reduced the Number of Candidates Evaluated (NCE), often identifying optimal repairs by checking only a tiny fraction of the search space.
- Scalability: The approach demonstrates near-linear scalability with dataset size, making it suitable for large-scale production environments.
Conclusion and Future Work
This work demonstrates that combining hierarchical data partitioning with interval arithmetic provides a robust solution for repairing queries with complex aggregate constraints. While the current implementation focuses on adjusting constants within existing predicates, future research will explore more expressive bounding techniques and the ability to modify query structures, such as adding or removing entire predicates or changing join conditions.
Summary updated