Skip to main content

Query Apache Hudi Tables in DuckDB

20 min read
Apache Hudi and DuckDB logos. Query Apache Hudi tables in DuckDB. INSTALL hudi FROM community;

DuckDB can now read Apache Hudi tables. The DuckDB Hudi extension reads Copy-on-Write and Merge-on-Read tables from the DuckDB CLI, Python, or any application that embeds DuckDB. You don't need Spark or a JVM:

INSTALL hudi FROM community;
LOAD hudi;
SELECT * FROM hudi_scan('s3://my-bucket/warehouse/trips');

The extension supports snapshot, time-travel and incremental queries, and uses WHERE filters to skip partitions and files. On the 22 TPC-H queries over Copy-on-Write tables on Amazon S3, the extension runs about as fast as DuckDB reading Apache Parquet tables.

Why Hudi in DuckDB​

Apache Hudi is an open data lakehouse platform. Hudi tables store data in open file formats such as Parquet on cloud storage, and Hudi is built for data that changes: Hudi applies record-level upserts and deletes quickly using indexes, ingests streams and change data capture (CDC) with low latency, and keeps tables fast with built-in compaction, clustering and cleaning. Because Hudi records every commit, you can read a table as of an earlier commit, or read only the records that changed.

Many queries now run on a single machine: in a terminal, a notebook, a CI job or an AI agent's tool call. DuckDB is a common engine for these queries: a simple, fast, in-process analytical database for data that fits on one machine. With the extension, you can check what yesterday's upserts changed from the DuckDB CLI, debug a pipeline commit by commit, rebuild a training set as of a past date, or let an agent query the lakehouse directly.

Getting Started​

A quick refresher on what the extension handles. A Hudi table keeps a timeline of commits under .hoodie/, and each commit points to the file versions that make up the table at that point. A correct read uses the timeline to pick the latest file slices and, on a Merge-on-Read table, merges the log files into the base files. The extension does both, so DuckDB returns the same rows as Spark or Trino.

The extension runs on Linux, macOS and Windows, with builds for DuckDB 1.5 and 2.0. This post covers the build for DuckDB 2.0, the latest release. Install the extension once, then load the extension in each session:

INSTALL hudi FROM community;
LOAD hudi;

To update an earlier install, run FORCE INSTALL hudi FROM community;.

Query a table by path. hudi_scan works like any other table in DuckDB, in filters, joins, aggregates and views. read_hudi is an alias of hudi_scan and also works on earlier versions of the extension:

CREATE VIEW trips AS SELECT * FROM hudi_scan('/data/hudi/trips');

SELECT city, count(*) AS rides, avg(fare) AS avg_fare
FROM trips
WHERE trip_date >= DATE '2026-11-01'
GROUP BY city
ORDER BY rides DESC;

Each query reads the latest commit, so the view shows current data even while a Spark or Flink job keeps writing to the table.

Cloud storage​

For a table on Amazon S3, load httpfs and create a secret, as you would for read_parquet:

INSTALL httpfs;
LOAD httpfs;
CREATE SECRET (TYPE s3, PROVIDER credential_chain);

SELECT count(*) FROM hudi_scan('s3://my-bucket/warehouse/trips');

The extension reads the table with this secret, and reads the data files through DuckDB's file cache. The credential_chain provider picks up an AWS profile or an SSO login, as it does for read_parquet (supported in v0.4.0 and above). Earlier versions list the table's timeline and partitions with credentials from the standard AWS_* environment variables or the instance's IAM role. For Google Cloud Storage and Azure Blob Storage, set the GOOGLE_* and AZURE_* environment variables.

Python​

The extension works with the regular duckdb package, and results convert to pandas or Polars (pip install duckdb pandas polars pyarrow):

import duckdb

con = duckdb.connect()
con.sql("INSTALL hudi FROM community; LOAD hudi;")

rel = con.sql("""
SELECT city, count(*) AS rides
FROM hudi_scan('/data/hudi/trips')
GROUP BY city
""")
pandas_df = rel.df()
polars_df = rel.pl()

Time Travel and Incremental Queries​

Hudi records every change as a commit on the table's timeline. The extension exposes that history in SQL.

The timeline as a table. hudi_commits lists the table's commits, which is how you find the instants to pass to as_of and start. hudi_info summarizes the table, and hudi_files lists the table's file slices:

SELECT timestamp, action, completion
FROM hudi_commits('/data/hudi/trips')
ORDER BY timestamp DESC
LIMIT 5;

SELECT hudi_info('/data/hudi/trips');

Time travel. Pass an instant as as_of to read the table as of the latest commit at or before that instant. Time travel can reproduce the training set a model saw, or check what a report showed last week:

SELECT count(*)
FROM hudi_scan('/data/hudi/trips', as_of => '20261101000000000');

Incremental queries. Pass an instant as start to read only the rows written by commits after that instant. An optional "end" instant closes the window and is inclusive, so the query reads commits after start up to and including "end" (end is a reserved word in DuckDB and needs quotes). A downstream job can process only what changed since the job's last run, instead of rescanning the full table:

SELECT *
FROM hudi_scan('/data/hudi/trips',
start => '20261128000000000',
"end" => '20261129000000000');

On tables at table version 8 and above, start and "end" compare commit completion times, shown in the completion column of hudi_commits. An incremental query returns each changed row once, as of the end of the window, and no deleted rows; a full change log needs a change data capture (CDC) query, which is in progress.

Both kinds of query need the files of the commits they read. Time travel reaches back to the oldest commit whose files the cleaner has kept, and incremental queries cover the commits on the active timeline.

Filter Pushdown​

The extension uses WHERE filters to skip partitions and files before reading any data. The extension prunes partitions by partition value. On Copy-on-Write tables and read-optimized queries, the extension also skips files using column stats (min and max values): from the metadata table's column stats index when the table has one, otherwise from each base file's Parquet footer. A = or IN filter on the record key of the latest snapshot reads only the file groups that the metadata table's record index identifies. EXPLAIN shows the filters the extension received and how much of the table is left to read:

EXPLAIN SELECT * FROM hudi_scan('/data/hudi/orders')
WHERE region = 'us' AND order_date >= DATE '2026-01-01';
HUDI_SCAN
Table: /data/hudi/orders
Query: snapshot
Hudi Filters: region = us AND order_date >= 2026-01-01
Partitions: 1 / 12
File Slices: 3 / 40

This query reads 3 of the table's 40 file slices. Time-travel and incremental queries are pruned the same way.

Joins benefit too, through DuckDB's dynamic join filters. When a Hudi table is joined with a smaller, filtered table, DuckDB builds a filter from the join keys while the query runs. The scan applies that filter, so rows that cannot match never reach the join.

What's Supported​

In a nutshell, the extension reads the tables most Hudi users have today:

  • Hudi versions: tables written by Hudi 0.14 and later (table versions 6, 8 and 9).
  • Table types and queries: Copy-on-Write and Merge-on-Read tables, with snapshot, read-optimized, time-travel and incremental queries.
  • Table layouts: partitioned and non-partitioned tables with the built-in key generators, including tables that have been through updates, deletes, clustering, insert overwrite, rollbacks and savepoint restores.
  • Schema evolution: added columns and widened column types.
  • File formats: Parquet base files, plus Lance base files (table version 9).
  • Storage: local disk, Amazon S3, Google Cloud Storage and Azure Blob Storage.
  • Platforms: Linux, macOS and Windows, on DuckDB 1.5 and 2.0 (the features in this post need 2.0). On Windows, give local tables as file:// URIs.

These are in progress and will be supported in future releases:

  • Looking up tables by name in a catalog, such as the Hive Metastore or the AWS Glue Data Catalog, instead of by path.
  • Bootstrap tables, and columns renamed with schema-on-read evolution.
  • Custom payload classes and partial updates on tables before table version 9.
  • Data skipping with the metadata table's other indexes, such as the secondary index.
  • Change data capture (CDC) queries and reads of the archived timeline.
  • Writes.
  • In-browser (WebAssembly) builds.

How It Works​

The extension is a C++ DuckDB extension on top of hudi-rs, the native Rust implementation of Hudi from the Apache Hudi community. For each query:

  1. DuckDB passes the query's filters and columns to the scan.
  2. hudi-rs reads the timeline, finds the file slices of the requested snapshot, and prunes partitions and files with the filters. This planning runs in the background while DuckDB optimizes the rest of the query.
  3. hudi-rs reads the base files, merges the log files of Merge-on-Read file slices, and returns Apache Arrow batches, which DuckDB imports over the Arrow C Data Interface.
  4. On cloud storage, the data files are read through DuckDB's own file system, so the extension shares DuckDB's secrets and file cache with read_parquet.
DuckDB passes filters and columns to hudi_scan, which asks hudi-rs for a snapshot; hudi-rs reads the timeline, plans file slices, prunes and merges log files, and returns Arrow batches; data files are read through DuckDB's file system and cache, and hudi-rs reads the timeline and metadata and lists the table's files, all from one Hudi table: the .hoodie/ timeline and metadata, base files and log files

Within a session, the extension caches opened tables and read plans. A later query checks the timeline, and reuses the cached table and plan if no commit happened in between.

All of Hudi's read logic lives in hudi-rs: the timeline, file listing, merging log files and handling each table version. The same library powers Hudi reads from Python and Rust, Apache DataFusion, Daft and Ray. A fix or feature in hudi-rs reaches DuckDB with a version bump, and every engine on hudi-rs reads a table the same way.

Performance​

We ran the 22 TPC-H queries on DuckDB 2.0.1 over Copy-on-Write tables on Amazon S3, at scale factors 1, 10 and 100 (about 1, 10 and 100 GB of raw data). Cold runs start each query in a fresh DuckDB process; warm runs then repeat the query in the same process. In both, the tables are opened before the timer starts. The baseline is read_parquet reading the same Parquet files the Hudi tables contain, so the difference is the cost of reading those files as a Hudi table. Each time is the sum over the 22 queries, and a ratio of 1.0 means Hudi adds nothing.

Total time for the 22 TPC-H queries on Amazon S3 on DuckDB 2.0.1, hudi_scan against read_parquet. Cold, each query in a fresh process: SF1 14.63 s against 14.25 s, SF10 34.10 s against 33.26 s, SF100 172.81 s against 167.58 s, 1.03x at every scale. Warm, in one session after a first run: SF1 4.83 s against 5.25 s (0.92x), SF10 16.28 s against 17.08 s (0.95x), SF100 129.68 s against 131.34 s (0.99x).
Scale factorCold read_parquetCold hudi_scanCold ratioWarm read_parquetWarm hudi_scanWarm ratio
114.25 s14.63 s1.03x5.25 s4.83 s0.92x
1033.26 s34.10 s1.03x17.08 s16.28 s0.95x
100167.58 s172.81 s1.03x131.34 s129.68 s0.99x
Per-query cold results

Each value is the query's median over 4 cold runs, in seconds.

QuerySF1 read_parquetSF1 hudi_scanSF10 read_parquetSF10 hudi_scanSF100 read_parquetSF100 hudi_scan
Q10.460.601.301.859.4812.01
Q20.480.510.950.832.542.70
Q30.890.791.511.647.998.41
Q40.640.571.041.013.764.43
Q50.910.851.872.159.299.40
Q60.380.471.131.096.105.52
Q70.840.721.861.649.289.91
Q80.961.142.152.0310.5311.62
Q90.960.892.672.8014.5615.46
Q100.830.862.452.458.829.57
Q110.310.350.820.662.261.98
Q120.590.601.051.204.196.14
Q130.670.661.201.537.727.05
Q140.590.611.301.427.076.89
Q150.460.521.741.2511.856.70
Q160.280.400.930.781.841.93
Q170.620.641.581.629.369.51
Q180.800.661.341.6510.2610.50
Q190.640.661.451.707.789.52
Q200.710.781.991.818.067.81
Q210.770.861.901.9712.4613.28
Q220.440.491.031.032.382.44
Per-query warm results

Each value is the query's median over 5 warm runs, in seconds.

QuerySF1 read_parquetSF1 hudi_scanSF10 read_parquetSF10 hudi_scanSF100 read_parquetSF100 hudi_scan
Q10.180.230.911.138.1610.40
Q20.310.270.480.331.871.82
Q30.230.210.700.755.876.27
Q40.130.120.350.362.443.04
Q50.270.290.880.896.776.97
Q60.130.110.570.475.024.04
Q70.290.250.880.796.907.05
Q80.340.280.990.977.608.41
Q90.370.331.491.3711.6211.47
Q100.410.331.481.286.757.25
Q110.160.130.350.181.520.93
Q120.150.170.380.542.834.48
Q130.410.300.700.926.705.57
Q140.160.150.660.575.314.47
Q150.220.151.190.5310.374.47
Q160.140.130.260.241.071.04
Q170.240.210.930.857.757.58
Q180.200.280.640.928.519.14
Q190.180.200.730.855.907.39
Q200.260.220.850.705.895.13
Q210.330.311.191.2111.0811.40
Q220.150.140.490.431.421.38

Both readers return the same results for all 22 queries. Cold, hudi_scan is about 3 percent slower than read_parquet at every scale. Warm, hudi_scan matches or slightly beats read_parquet (0.92x to 0.99x): within a session, the extension keeps each opened table and its plans, and only checks that the timeline has not moved. At scale factor 100, hudi_scan is faster on 6 of the 22 queries cold and 11 warm. The biggest difference is Q15 (6.7 s against 11.8 s cold), which reads a view over lineitem twice: DuckDB's optimizer shares one hudi_scan between both reads, but runs read_parquet twice.

Seconds per TPC-H query at scale factor 100 on Amazon S3 on DuckDB 2.0.1, hudi_scan against read_parquet, in two panels on one scale. Cold, each query in a fresh process (median of 4 runs): the ratio ranges from 0.57x on Q15 (6.70 s against 11.85 s) to 1.47x on Q12 (6.14 s against 4.19 s), and hudi_scan is faster on 6 queries. Warm, in one session (median of 5 runs after a first run): the ratio ranges from 0.43x on Q15 to 1.59x on Q12, and hudi_scan is faster on 11 queries. Q1, Q12 and Q19 trail in both.

A few queries still trail read_parquet, cold and warm, and upcoming releases target each cause:

  • Q1 (12.0 s against 9.5 s cold at scale factor 100) reads almost every row of lineitem and groups by two short string columns. read_parquet passes those columns to DuckDB still dictionary-encoded, so the aggregation hashes each distinct value instead of every row, while hudi-rs decodes them into plain Arrow strings.
  • Q12 and Q19 (6.1 s against 4.2 s, and 9.5 s against 7.8 s) filter lineitem down to a few percent of the rows by ship mode, shipping instructions and dates. read_parquet applies those filters while decoding and reads the other columns only for the matching rows, while hudi_scan decodes every column the query reads first.
  • Tables with few files: a scan splits work by file slice, not by row group, which limits parallelism.

What's Next lists the work on each.

How we measured
  • Instance: c6id.4xlarge (16 vCPUs, 32 GiB memory) in the same AWS region as the S3 bucket.
  • Software: DuckDB 2.0.1 with default settings (16 threads) for both readers. The hudi extension is built from commit bdd19db with #24 (DuckDB 2.0.1) and #25 (hudi-rs 5d46686e), the code for the upcoming v0.4.0 release.
  • Storage access: both readers load httpfs and use the same credential_chain secret, as in Cloud storage. hudi_scan reads data files through DuckDB's file system and file cache, as read_parquet does, and lists the table's timeline and partitions with hudi-rs's own client (the instance's IAM role here).
  • Tables: TPC-H, Copy-on-Write, written by Apache Hudi 1.1 on Apache Spark 3.5 (table version 9) in one commit. Base files are Parquet with GZIP compression.
  • Validation: before timing, all 22 queries return the same results from hudi_scan and read_parquet at every scale factor.
  • Cold runs: each query runs in a fresh process. The views over the tables are created before the timer starts, which opens each table, so the time covers the query itself. hudi_scan and read_parquet alternate, in an order that rotates each round, for 4 rounds. We report each query's median, summed over the 22 queries.
  • Warm runs: each query runs in a fresh process, with the views created first as for cold runs. The query runs once, then 5 more times in the same process, and we report the median of those 5, summed over the 22 queries.
  • Absolute times: the times reflect GZIP, Hudi's default codec, and reads over the network. The same queries run faster on Snappy or ZSTD files, on local disk, or in DuckDB's own storage format.
  • Harness: tpch_cold.sh for cold runs and tpch_warm.sh for warm runs, so anyone can reproduce these numbers (with the upcoming v0.4.0 release of the extension).

What's Next​

We keep improving the performance of the DuckDB Hudi extension: reading base files with DuckDB's own Parquet reader, splitting scans by row group, applying filters while decoding, and pushing join filters into hudi-rs. Next, the metadata table's other indexes, such as the secondary index, will let selective queries on large tables read less, and catalog support will let you query a table by name. Later, we would like DuckDB to write Hudi tables, building on the native write support in hudi-rs 0.6.0.

Contributions are welcome, from bug reports and feature requests to code. The extension's code and Hudi's read logic in hudi-rs are both on GitHub. Try the extension on your own tables and tell us what works and what doesn't on GitHub, or in the Apache Hudi community on Slack, LinkedIn, X and the dev@hudi.apache.org mailing list.

DuckDB is a trademark of the DuckDB Foundation. Apache, Apache Hudi and Hudi are trademarks of The Apache Software Foundation.