Abstract
Modern data analysis frequently involves complex nested structures like JSON or NoSQL records, which distributed systems like Apache Spark struggle to process efficiently. This paper presents a framework that translates high-level Nested Relational Calculus (NRC) programs into "shredded" relational queries. By decomposing nested data into flat collections and implementing automated skew-handling, the system achieves up to 25x performance improvements over traditional flattening methods while maintaining scalability for deeply nested datasets.
Introduction
Modern data analysis often involves nested data—collections within collections, such as a customer record containing a list of orders, each containing a list of parts. While distributed systems like Apache Spark are excellent for flat data, they struggle with nesting. Currently, developers face a "programming mismatch": they must either manually rewrite complex nested logic into flat relational joins—a process prone to error—or rely on automated "flattening" procedures. Standard flattening often leads to massive data duplication, memory crashes, and severe load imbalances. Furthermore, when specific inner collections are much larger than others (data skew), standard partitioning strategies fail, causing some worker nodes to be overwhelmed while others sit idle.
Methodology
The authors propose a three-pronged approach to bridge the gap between high-level nested logic and low-level distributed execution.
1. Query Shredding
Instead of flattening a nested object into one giant, redundant table, the framework "shreds" it. It creates a top-level flat collection and a "dictionary tree" of separate flat collections for each level of nesting. This representation is more succinct and allows for "localized" operations, avoiding the duplication of "outer" information for every "inner" element.
2. Compilation Pipeline
The system takes programs written in Nested Relational Calculus (NRC) and automatically compiles them into optimized algebraic plans. This includes a Materialization Algorithm that converts symbolic dictionary lookups into efficient relational joins.
3. Skew-Resilient Processing
The framework uses a lightweight sampling technique at runtime to identify "heavy" keys (those associated with disproportionately large amounts of data). It then splits the execution path: "light" keys are processed using standard partitioning, while "heavy" keys are handled using specialized strategies like broadcast joins to prevent node crashes.
Evaluation and Results
The framework was evaluated using two primary benchmarks: Nested TPC-H, a variant of the industry-standard database modified for up to four levels of nesting, and a Biomedical Benchmark (ICGC) involving complex multi-omic analyses.
Key results include:
- Performance Gains: For flat-to-nested queries, the shredded variant showed up to a 25x gain in performance compared to standard methods.
- Scalability: The framework successfully processed queries with 4 levels of nesting, whereas standard flattening methods failed to complete or crashed due to memory limits.
- Skew Handling: The skew-aware shredded route outperformed flattening by 15x in runtime and reduced data shuffling by 33x for moderately skewed datasets.
- Succinctness: In the biomedical dataset, the shredded representation reduced the total size of certain transcript tables by over 1 million tuples compared to the standard representation.
Conclusion and Future Work
While the framework provides a robust automated pipeline, several areas for improvement remain. The current system relies on rule-based optimizations; the authors identify "cost estimation"—predicting the most efficient plan based on data statistics—as a crucial next step. Additionally, while the theory is general, the current implementation is heavily optimized for Apache Spark's Dataset API. Future work includes porting these optimizations to other engines like Flink or Presto and addressing the challenges of high-frequency updates to shredded nested structures.
Summary updated