Add support for manually optimizing a table#406
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds end-to-end support for manually optimizing (compacting) Delta Lake tables via a new OPTIMIZE [CLUSTER] ... [TARGET ...] SQL statement, exposed through the Arrow Flight server, embedded client, C API, and Python bindings.
Changes:
- Extend the SQL parser/dialect to recognize
OPTIMIZE(includingCLUSTERandTARGET). - Add storage/server/cluster execution paths to run optimize locally or across a cluster via Flight
do_get(). - Add embedded/C/Python APIs and unit/integration tests covering optimize behavior and error cases.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/modelardb_storage/src/parser.rs | Adds OPTIMIZE statement parsing and statement mapping into ModelarDbStatement. |
| crates/modelardb_storage/src/data_folder/mod.rs | Introduces DataFolder::optimize_table() and unit tests validating file compaction behavior. |
| crates/modelardb_server/tests/integration_test.rs | Adds Flight-level integration tests for optimizing tables and missing-table errors. |
| crates/modelardb_server/src/remote.rs | Wires OPTIMIZE into Flight do_get() and adds optimize_tables() handler logic. |
| crates/modelardb_server/src/context.rs | Adds Context::optimize_table() plus related unit tests. |
| crates/modelardb_server/src/cluster.rs | Adds cluster-wide optimize support (optimize_cluster_tables). |
| crates/modelardb_embedded/src/operations/mod.rs | Extends embedded Operations trait with optimize(). |
| crates/modelardb_embedded/src/operations/data_folder.rs | Implements optimize() for embedded DataFolder and adds unit tests. |
| crates/modelardb_embedded/src/operations/client.rs | Implements optimize() for embedded Flight Client. |
| crates/modelardb_embedded/src/capi.rs | Adds C ABI entrypoint modelardb_embedded_optimize. |
| crates/modelardb_embedded/bindings/python/tests/test_operations.py | Adds Python binding tests for optimize success/error. |
| crates/modelardb_embedded/bindings/python/modelardb/operations.py | Exposes optimize() in Python API via the C ABI. |
| crates/modelardb_embedded/bindings/c/modelardb_embedded.h | Declares the new C API function for optimize. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
chrthomsen
approved these changes
Jul 2, 2026
skejserjensen
requested changes
Jul 2, 2026
This was referenced Jul 3, 2026
skejserjensen
approved these changes
Jul 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR closes #239 by adding a new method to
DataFolder, addingOPTIMIZE [CLUSTER] [table_name[, table_name]+] [TARGET num_bytes]to the SQL parser, adding a new method toCluster, adding the structure inContextand the Apache Arrow Flight server to call optimize, and adding optimize tomodelardb_embeddedand the Python library.Unit testing have also been added in the relevant places and three new integration tests have been added to ensure the Apache Arrow Flight endpoint works. Note that the implementation matches
vacuum1-to-1.