Skip to content
Preprint

DAGSmith: Dependency-Aware Rewriting for dbt-Style SQL Pipelines

Aug 2026 · 0 citations · 28 references
Computer Science

TL;DR

DAGSmith is introduced, to the best of the authors' knowledge the first holistic dependency-aware source-to-source rewriting system for SQL pipeline DAGs and enables dependency-edge simplification, non-local semantic reuse, downstream-aware pruning, pipeline-aware work placement, rewrite-materialization co-optimization, and frequency-aware optimization.

Abstract

Modern analytics is increasingly organized as recurring SQL pipelines rather than isolated SQL statements. Tools such as dbt, which have gained extreme popularity in recent years, allow teams to write each transformation as SQL and make dependencies between transformations explicit, producing directed acyclic graphs (DAGs) with hundreds or thousands of interdependent SQL models. Traditional query optimizers and source-to-source query rewriters operate on one query at a time, while materialized-view selection and multi-query optimization address narrower forms of reuse. They do not exploit the pipeline-level information exposed by explicit dependencies: how intermediate results are consumed, which downstream outputs depend on each computation, where expensive work sits relative to data reduction, which results are worth persisting, and how refresh schedules relate to input change and output demand. We introduce DAGSmith, to the best of our knowledge the first holistic dependency-aware source-to-source rewriting system for SQL pipeline DAGs. DAGSmith treats explicit dependencies as optimization signals. It analyzes each transformation with its upstream inputs, downstream consumers, and position in the pipeline DAG, uses an LLM to propose pipeline-level refactorings, separates SQL generation and equivalence checking to reject unsafe rewrites, retunes persistence choices with a learned cost model, and selects a globally compatible, conflict-free set of rewrites. This enables dependency-edge simplification, non-local semantic reuse, downstream-aware pruning, pipeline-aware work placement, rewrite-materialization co-optimization, and frequency-aware optimization. On the open-source Tuva dbt project, DAGSmith reduces elapsed time by 42.6% and warehouse compute cost by 67.7%, 98.1%/348.3% larger than state-of-the-art single-query rewriting.

View source

Similar papers

Apr 2026

BatchDAG: LLM-Planned Execution Graphs for Scalable Ad-Hoc Analysis Over Enterprise Data

BatchDAG is a general-purpose orchestration layer that replaces multiple hand-engineered workflows with a single system that generates the appropriate execution strategy from natural language, and is not primarily an accuracy improvement over hand-optimized pipelines.

Anupreet Walia · 0 citations
Open access Jul 2026

Benchmarking the Full Pipeline of Materialized-View-Based Query Rewriting

This paper benchmarks MV-based query rewriting by jointly evaluating enumeration, selection, and rewriting with a modular evaluation framework and by using controlled ablations, and introduces a cross-engine protocol allowing us to compare systems that expose only execution plans by contrasting native optimizer-level rewriting with portable SQL rewriting baselines when available.

Xin-Jie Hu, Zheng-Jie Miao · 0 citations
Preprint Aug 2026

AutoSQL: Extracting SQL Templates from Imperative ORM Code in Large-Scale Repositories

This work presents AutoSQL, a system that reconstructs SQL templates from Go ORM code that constructs a Code Index, a directed graph that captures structural dependencies between functions, types, and global variables as navigable edges and synthesizes SQL templates.

Junsong Pu, Yichen Li, Zhuangbin Chen et al. · 0 citations
Jul 2026

Kalypso: Relational LLM Serving

Kalypso is presented, a relational LLM serving system that exposes an API for semantic query plans and executes them using an adaptive, memory-aware scheduling algorithm, demonstrating that query-aware LLM serving can substantially improve the efficiency of semantic query execution.

Hojae Son, Md Ashraful Islam, H. Cao et al. · 0 citations
Jul 2026

The Data World is Not Flat: Efficient Factorized Execution for Relational Systems

Relational database management systems (RDBMSs) struggle with efficient execution of graph workloads, particularly those involving many-to-many joins with large intermediate results. Such joins are common in modern applications such as social networks, recommendation engines, and knowledge graphs. Traditional RDBMSs are optimized for selective joins, while the typical result blow-up in graph analytics leads to exceptionally long query times or even system crashes due to out-of-memory errors. Since graph and relational data are often intertwined, a unified solution can simplify system architecture and improve performance. To address this, we propose a novel code-generating engine with factorization, which represents tuples in a hierarchical form. Our approach enables intra-query-parallelized query execution on factorized representations and generates code to overcome their CPU-unfriendly layout. Additionally, we extend current factorized approaches by bottom-inserts to make joins reorderable. Our factorized approach can outperform traditional tuple representations and state-of-the-art RDBMSs by orders of magnitude on synthetic workloads and benchmarks as our experiments show. Moreover, its potential integrability into traditional RDBMSs enables efficient processing of complex, highly redundant queries, offering a unified and scalable solution for modern workloads.

Stefan Lehner, Thomas Neumann · 0 citations

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.