Which command compacts small Parquet files in a Delta table?
Why A is the answer
OPTIMIZE
OPTIMIZE compacts files. VACUUM removes files no longer referenced.
In detail
- OPTIMIZE compacts small files.
- OPTIMIZE and VACUUM do different jobs.
Use case
An illustrative scenario, not a real incident.
Small writes leave thousands of Parquet files in a table. OPTIMIZE compacts them, and VACUUM later removes the old files.
See it in different ways
flowchart LR A["Many small files"] --> B["OPTIMIZE compacts them"] B --> C["VACUUM removes unreferenced files"] C --> D["Faster reads"]
stateDiagram-v2 [*] --> SmallFiles: many small writes SmallFiles --> Compact: OPTIMIZE Compact --> Sorted: V-Order or Z-Order Sorted --> Cleaned: VACUUM removes unreferenced files Cleaned --> SmallFiles: more writes
flowchart TD
Q{"What do you need?"}
Q -->|"Fewer small files"| A0["OPTIMIZE"]
Q -->|"Remove unreferenced files"| A1["VACUUM"]Key point: OPTIMIZE compacts small files.
Why the other options are wrong
- B. VACUUM
- VACUUM removes old files.
- C. DESCRIBE HISTORY
- That shows table history.
- D. SHOW TABLES
- That lists tables.

