Updated on 2026-06-27 GMT+08:00

Hudi Cleaning

Scenarios

Hudi is an open-source framework for efficient data management and incremental processing on Hadoop-compatible storage. Hudi supports multiple operations, including insert, update, delete, and incremental processing. Cleaning is a core Hudi function. It removes outdated data files to optimize storage and query performance.

  • Storage optimization: Over time, Hudi tables accumulate many small files and outdated data files. These files consume significant storage space and degrade query performance.
  • Improved query performance: Periodically cleaning outdated data files reduces the file count and improves query performance.

Performing Cleaning

Hudi uses the cleaner working in the background to continuously delete unnecessary data of old versions. You can configure hoodie.cleaner.policy and hoodie.cleaner.commits.retained to use different cleaning policies and determine the number of saved commits.

You can use either of the following methods to perform cleaning:

  • Synchronous cleaning is controlled by the hoodie.clean.automatic parameter, which is automatically enabled by default.

    Disable synchronous cleaning:

    When a data source is written, you can use .option("hoodie.clean.automatic", "false") to disable automatic cleaning.

    When spark-sql is written, you can use set hoodie.clean.automatic=false; to disable automatic cleaning.

  • You can use spark-sql to perform asynchronous cleaning. For details, see CLEAN.

Helpful Links

For more cleaning parameters, see Compaction and Cleaning Configurations.