Maintenance Actions
Snowpack executes maintenance actions in the enum order defined by
snowpack.models.MaintenanceAction. The generated SQL examples come from
snowpack.spark.SparkQueryEngine.maintenance_sql.
Execution order
1. rewrite_data_files
Trigger: The table has enough undersized data files or delete-file pressure to trigger compaction.
Compacts small data files and rewrites delete-heavy data files using Iceberg’s binpack strategy.
/* {"app": "snowpack", "table": "my_database.my_table", "action": "REWRITE_DATA_FILES"} */CALL lakehouse_dev.system.rewrite_data_files( table => 'my_database.my_table', strategy => 'binpack', options => map( 'target-file-size-bytes', '536870912', 'min-file-size-bytes', '402653184', 'max-file-size-bytes', '966367641', 'min-input-files', '5', 'delete-file-threshold', '2', 'delete-ratio-threshold', '0.1', 'partial-progress.enabled', 'true', 'partial-progress.max-commits', '10' ))2. rewrite_position_delete_files
Trigger: The table has position-delete files above the configured threshold.
Compacts position-delete files and removes dangling delete records after data-file rewrites.
/* {"app": "snowpack", "table": "my_database.my_table", "action": "REWRITE_POSITION_DELETE_FILES"} */CALL lakehouse_dev.system.rewrite_position_delete_files( table => 'my_database.my_table', options => map( 'partial-progress.enabled', 'true', 'partial-progress.max-commits', '10' ))3. expire_snapshots
Trigger: The table has old snapshots or compaction created snapshots that should be cleaned up.
Expires old snapshots while retaining the configured minimum snapshot count.
/* {"app": "snowpack", "table": "my_database.my_table", "action": "EXPIRE_SNAPSHOTS"} */CALL lakehouse_dev.system.expire_snapshots( table => 'my_database.my_table', older_than => TIMESTAMP '2026-04-20 00:00:00.000', retain_last => 3, stream_results => true)4. rewrite_manifests
Trigger: The table has enough manifest files to justify metadata consolidation.
Consolidates manifests after snapshot expiration to reduce planning overhead.
/* {"app": "snowpack", "table": "my_database.my_table", "action": "REWRITE_MANIFESTS"} */CALL lakehouse_dev.system.rewrite_manifests(table => 'my_database.my_table')5. remove_orphan_files
Trigger: Runs after snapshot expiration so unreferenced files can be removed safely.
Deletes files under the table location that no active snapshot references.
/* {"app": "snowpack", "table": "my_database.my_table", "action": "REMOVE_ORPHAN_FILES"} */CALL lakehouse_dev.system.remove_orphan_files( table => 'my_database.my_table', older_than => TIMESTAMP '2026-04-22 00:00:00.000', location => 's3a://example-bucket/my_database/my_table')