Inside Apache DataFusion: The LLVM of Databases
How does a query against 1,000 Parquet files end up opening just one? Andrew Lamb walks through DataFusion’s internals: pruning, dynamic filters, Parquet’s evolution, the life of a query, and going distributed.

Two years ago, Andrew Lamb joined me on The GeekNarrator to talk about the FDAP stack. A lot has happened since. Apache DataFusion — the extensible query engine written in Rust — has entered what Andrew calls its maturation phase: companies from small startups to Cloudflare, Apple and Palantir build real products on it, it sits at the top of the ClickBench leaderboard when querying Parquet, and the community has spent two years on two things — raw performance and extension points.
In this episode, Andrew (Apache DataFusion PMC, Staff Engineer at InfluxData) walked through the engine end to end. This post is the condensed version: the ideas, the internals, and the diagrams we used in the video.
The LLVM of databases
Andrew has long compared DataFusion to LLVM: a shared, reusable middle layer that lets anyone build a new front-end (SQL, DataFrames, a domain-specific language) or a new back-end (Parquet on object storage, a custom format) without rebuilding the hard parts in between.

His bigger thesis is about bespoke software. In the mainframe era every company wrote its own software. Packaged software won for the next few decades because it was cheaper than hiring experts to write and maintain your own. Coding agents are collapsing that cost — so bespoke is coming back, but this time assembled from solid components rather than written from scratch. That is already visible in what people build on DataFusion: streaming systems, SQL engines for genomic data, geospatial weather analysis — all leaning on the most important idea in database research: separating what you want to compute (the logical plan) from how to compute it (the physical plan).
His boldest prediction: we’re heading toward a world where nearly all data is queried with SQL, sitting in front of a wide variety of specialized back-ends — and LLMs, which are very good at writing SQL, will slowly make bespoke query languages unnecessary.
A running example
To keep things concrete, we used a familiar setup: request logs stored as Parquet on S3 — billions of rows a day, one folder per day — plus a small, rarely changing metadata table mapping endpoints to services and teams. The question: over the last 30 days, which endpoints error the most?

Prune before you read
The name of the game in analytics is to do as little work as possible, and DataFusion does it in layers.
1. Files. The classic layout is Hive-style partitioning — low-cardinality columns become directories (day=2026-10-01/service=checkout/…). DataFusion lists the files under a prefix and applies your filters to the paths themselves, skipping entire files before opening anything.
2. Row groups. A Parquet file is split into horizontal strips called row groups (typically 20K–100K rows), and the footer stores min/max statistics for every column in every row group. DataFusion reads (and caches) only the footer first, then rules out every row group whose range can’t possibly match.

3. Pages. Inside a surviving row group, each column chunk is stored as pages. The page index (column index + offset index) has per-page statistics and byte offsets, so DataFusion can prune again and fetch only the byte ranges it needs — then decompress, decode and evaluate the predicate.

Each level is cheaper to check than the data it rules out. That funnel — files → row groups → pages → rows — is the backbone of DataFusion’s Parquet performance.
Dynamic filters: read one file, skip 999
Plan-time pruning only works with what the query tells you (WHERE user = 'andrew'). Some of the most valuable information only appears while the query runs. That’s what dynamic filters exploit — and it’s the optimization Andrew is proudest of.
Take a TopK query: ORDER BY ts DESC LIMIT 10 across 1,000 files. The naive approach sorts everything. A better one keeps a heap of the current top 10 — but still scans every file. DataFusion goes further:
- It orders files by their time statistics, newest first.
- The TopK operator keeps a heap; its 10th value becomes a running threshold.
- That threshold is pushed down into the scan as a filter (
ts > threshold), and pruning keeps happening as the query runs.

“You run a query against a thousand files. DataFusion will basically only open the first one, read a little bit of it, and stop — and that can prove the subsequent files can’t possibly match.”
The same mechanism powers joins, which we’ll come back to.
Design your layout around your predicates
Pruning only works if your data layout cooperates. Andrew’s guidance applies to any analytic database:
- Partition across files by the predicates most queries have — usually time. You skip whole files, and retention becomes “delete old partitions”.
- Cluster within files so row groups have disjoint ranges of the columns you filter on. The simplest way is to sort (e.g., by service); Z-order and Hilbert curves cluster on multiple columns at once.

Real workloads have several access patterns, which forces a trade-off: keep multiple copies organized differently (2–3× storage and ingest), or a compromise layout that’s OK for both and great for neither. Because DataFusion is a library rather than a closed system, you can plug in your own logic — a custom table provider that inspects predicates and picks the right copy, a special index, or vector search — instead of rewriting queries on top of the engine.
Parquet keeps evolving
Andrew is open about his bias — he’s on the Apache Parquet PMC — but his argument is compelling: Parquet has become the long-term archival standard because it’s stable and readable by basically everything. Rather than abandon it as new workloads arrive, the community is extending it:
- Variant — an efficient JSON-like type. Field names go into a dictionary instead of repeating on every row, and shredding stores common fields (timestamp, service, host) as native typed columns so predicates and statistics work on them.
- Geospatial types with per-row-group bounding boxes, so spatial predicates prune just like min/max.
- Vectors — standardization in progress.

The most common criticism, especially from ML and search workloads, is single-row lookups. To fetch one row you fetch a page per column, decompress the whole page, and decode run-length/bit-packed data sequentially up to your row — roughly a thousand times more work than the row you wanted. Tuning helps (a recent DataFusion blog post showed ~60× over a naive setup), but the real fix is new encodings: ALP for floats that are really fixed-precision decimals (now standardized; ~10× faster to decompress, with random access), plus FSST/OnPair symbol-table encodings for strings and FastLanes-style encodings for integers.

Andrew’s view on the bigger picture: one open format that many specialized engines can read beats a collection of proprietary silos. For latency-sensitive serving, you won’t read straight from S3 anyway — you’ll add a cache tier that keeps a different, query-friendly representation, transcoding Parquet on the fly (an idea he explored in research with PhD student Xiangpeng Hao).
The journey of a query
Here’s what happens between hitting enter and getting rows back.
Parse and bind. The query arrives as bytes. The SQL parser produces an AST — pure syntax; it has no idea whether logs is a real table. A planning step (SqlToRel, often called binding) walks the AST, resolves tables through a pluggable catalog, resolves column and function names, and produces a logical plan.

The logical plan is a tree of relational operators — scans at the leaves, data flowing up to the root. Notably it says nothing about hash vs. merge joins, TopK, or which of the 1,000 files to read.
Analyze and optimize. The analyzer adds type coercion (implicit casts). Then roughly 10–12 logical optimizer passes rewrite the tree: projection pushdown (carry only needed columns), filter pushdown (move filters as close to the source as possible), turning outer joins into inner joins, and more. Each pass is a tree rewrite built on DataFusion’s TreeNode API — and you can add your own.

Physical planning. The logical plan becomes an ExecutionPlan with concrete choices: HashJoinExec, SortExec with a TopK fetch, one of several grouping operators, and a scan with an actual file list. Then ~20 physical optimizer passes run. A key one tracks sortedness through the plan: if your source declares its data sorted by time, DataFusion can drop sorts and merge sorted streams instead. If input is sorted by the grouping key, it can use streaming aggregation — emitting each group as soon as the key changes, using far less memory than a hash table. Statistics can even answer COUNT(*) without reading data.

Execute. DataFusion is a streaming engine. Calling execute() returns an async stream of Arrow RecordBatches. It’s pull-based: asking the root for the next batch cascades down to the scan, which fetches, prunes and decodes Parquet, then pushes columnar batches back up. Arrow is used between every operator, not just at the edges.

Caching: built-ins and extension points
Out of the box, DataFusion provides an in-memory catalog (pluggable, e.g. for Iceberg), a cache of parsed Parquet metadata (around 50 MB by default), and data access through the object_store crate — with no built-in data cache. That’s deliberate: production systems add their own memory or NVMe caches and prefetching to keep S3 bandwidth saturated. Parquet makes this hard to do well because its reads depend on the query (footer, then metadata, then scattered pages), so recent work exposes more read-plan information to custom caches.
Going distributed
DataFusion core is single-node, but ships the boring essentials for distribution, like serializing plans to bytes. On top of that you have two options:
- Ballista, a batteries-included, Spark-style engine that materializes results between stages — resilient, but costly for short queries.
- datafusion-distributed, a newer library (with APIs shaped with folks from Datadog) that streams between nodes. For a 300 ms query, restarting beats spending 200 ms writing intermediate results to disk.
Distributing a scan and filter is easy. Aggregation is harder: aggregate as close to the data as possible, then hash-repartition by group key so each node finishes a disjoint slice.

Joins are hardest: matching keys must meet on the same machine, via hash repartitioning or broadcasting the small side. And many joins are really filters. With sideways information passing — DataFusion’s dynamic join filters — the build side’s few keys become an IN list pushed into the probe-side scan, where Parquet pruning kicks in. In a distributed plan those filters must cross the network, and with millions of keys a Bloom filter replaces the list. Range partitioning is next, so data that’s already laid out by time doesn’t need a reshuffle.

AI agents and open source
We ended on something every maintainer is feeling. Andrew says nearly every engineer he knows has stopped writing code by hand in the last six months — they review what agents write. He’s hopeful open-source components still matter: agents can assemble pre-built pieces like DataFusion far more cheaply than rebuilding them from scratch.
But the flood is real. DataFusion saw accounts open 10–12 PRs in a few hours, pages of LLM-generated descriptions, and around 400 open PRs — while trusted collaborators’ work waited. Andrew’s long-standing approach of reviewing every new contributor stopped scaling. In the weeks before we recorded, the community responded:

Things are already much better. As Andrew put it, it’s not about accepting as much code as possible — reviewer time is the scarce resource, and it’s best spent on people who want to become part of the community.
Parting advice
Andrew’s suggestion is refreshingly practical: sprinkle some DataFusion on it. Whatever data project you have, ask your agent to build a SQL interface for it with DataFusion, then let your agent query it with SQL. “I’ll bet you’ll be surprised at how cool the result is.”
Watch the full episode on The GeekNarrator YouTube channel for the complete conversation, with chapters for every section above.
Links: Apache DataFusion · DataFusion on GitHub · datafusion-distributed · Ballista · Apache Parquet · Apache Arrow · ClickBench

Comments & Discussion