Skip to main content
BRILLIQS

Apache Hudi

A data lake platform built around record keys, so individual rows can be updated and changes can be read incrementally.

Apache Hudi is an open source data lake platform. Each record in a Hudi table carries a key, which lets the table accept updates and deletes for single records rather than rewriting whole partitions. Hudi also keeps a timeline of every action on the table, so a job can ask for only the records that changed since it last ran.

What Apache Hudi is for

Apache Hudi is a data lake platform for tables that change. The documentation describes it as bringing database and data warehouse capabilities to the data lake, and the two capabilities it is best known for are record level updates and incremental reads.

Both come from the same design decision. Every record in a Hudi table carries a key, and Hudi keeps an index that maps that key to the file it lives in.

Why record keys change what is possible

A data lake table without keys can only be appended to or rebuilt. If ten rows out of a hundred million need correcting, the usual answer is to rewrite the partitions that contain them.

With a key and an index, Hudi can find the files holding those ten records and act on them directly. An incoming batch becomes an upsert: matching records are updated, the rest are inserted. Deletes work the same way, which matters when a record has to be removed on request.

Choosing a table type

Hudi offers two, and the choice is a trade between write cost and read cost.

Copy on write. Changes are applied when the data is written. The affected files are rewritten so the table always holds finished data. Reads are straightforward, writes do more work.

Merge on read. Changes are written into log files alongside the base files, and combined when the table is read. Writes finish faster, reads do more work, and a background compaction eventually folds the logs into the base files.

Frequent small changes usually point towards merge on read. Tables read far more often than they are written usually point towards copy on write.

The timeline and incremental queries

Hudi records every action against the table on a timeline. Commits, cleaning, compaction and clustering all appear there in order.

This is what makes incremental queries possible. A downstream job records the point it reached, and on the next run asks Hudi for the records committed since that point. Instead of scanning a full table to find what is new, the job reads a much smaller set.

Table services

A lake table left alone accumulates small files and drifting layouts. Hudi treats the fixes as services rather than as jobs you write:

  • Compaction merges log files into base files on merge on read tables.
  • Clustering reorganises data to improve how queries read it.
  • Cleaning removes older file versions that are no longer needed.
  • File sizing keeps written files within a sensible range.

Who tends to use Hudi

Hudi suits data engineering teams whose lake tables must reflect changing source systems, particularly where records are captured from a database and applied continuously. It is a platform rather than an end user tool, so it is normally chosen and operated by the team that owns the pipelines.

Things to weigh up

Hudi has more moving parts than a plain file format, because indexes, table services and table types all have to be configured. That configuration is where most of the effort goes.

The table type is also a commitment worth thinking through, since the right answer depends on how often the table changes and how it is read.

Getting started

The documentation includes a quick start guide with Spark and Flink examples that create a table, write to it, run an upsert and then read the table incrementally. There are separate pages covering table types, indexing and each table service.

Key features of Apache Hudi

Capabilities described in the official documentation.

Record keys and upserts

Every record has a key, so an incoming batch can update matching records and insert the rest in one operation.

Two table types

Copy on write rewrites files at write time for faster reads. Merge on read writes changes to log files and merges them at query time.

Incremental queries

A query can request only the records that changed between two points on the timeline instead of scanning the whole table.

Indexes to locate records

Hudi maintains indexes that map a record key to the file holding it, which is how an update finds its target quickly.

Advantages of Apache Hudi

Factual advantages that follow from the features above.

Changes cost less to apply

Updating a handful of records does not require rewriting an entire partition, because the index points at the files involved.

Downstream jobs can process less

Reading only what changed since the last run means a downstream job does not have to reprocess the full table each time.

Housekeeping is built in

Compaction, clustering, cleaning and file sizing run as table services rather than being written as separate jobs.

One table serves several query types

A table can be read as a current snapshot, as only what changed, or as its optimised base files.

Common use cases for Apache Hudi

Situations the official documentation describes this tool as being used for.

Data integration

Keeping a lake table in step with a database

Change records captured from a source database are applied as upserts so the lake table matches the source.

Compliance

Removing specific records on request

A delete is issued for records matching a key, which is needed when a person asks for their data to be removed.

Analytics engineering

Feeding downstream tables

A job reads only the commits added since its last run and updates a summary table from that smaller set.

Data platforms

Reducing the cost of a large refresh

Only the files holding changed records are rewritten rather than the whole partition each run.

Official website

Everything on this page is based on the official documentation for Apache Hudi. You can read the source here.

Apache Hudi official documentation

Frequently asked questions about Apache Hudi

Answers taken from the official documentation for this tool.

Copy on write applies changes when data is written, rewriting the affected files, which keeps reads simple and fast. Merge on read writes changes into log files first and combines them with the base files when the table is queried, which makes writes faster and reads more work.

The key identifies a record uniquely so Hudi can tell an update from an insert. Without it there would be no way to know that an incoming row replaces an existing one rather than adding a duplicate.

The timeline is an ordered record of every action taken on the table, including commits, cleaning and compaction. It is what allows Hudi to describe the table at a point in time and to answer queries about what changed between two points.

The documentation lists integrations with several engines including Spark, Flink, Hive, Presto and Trino. What each engine supports varies, so the engine pages in the documentation are worth checking for the query types you need.