Skip to content

Add support for manually optimizing a table#406

Merged
CGodiksen merged 42 commits into
mainfrom
dev/manual-optimize
Jul 3, 2026
Merged

Add support for manually optimizing a table#406
CGodiksen merged 42 commits into
mainfrom
dev/manual-optimize

Conversation

@CGodiksen

Copy link
Copy Markdown
Collaborator

This PR closes #239 by adding a new method to DataFolder, adding OPTIMIZE [CLUSTER] [table_name[, table_name]+] [TARGET num_bytes] to the SQL parser, adding a new method to Cluster, adding the structure in Context and the Apache Arrow Flight server to call optimize, and adding optimize to modelardb_embedded and 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 vacuum 1-to-1.

CGodiksen added 30 commits June 30, 2026 06:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (including CLUSTER and TARGET).
  • 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.

Comment thread crates/modelardb_storage/src/parser.rs
Comment thread crates/modelardb_storage/src/parser.rs
Comment thread crates/modelardb_embedded/src/capi.rs Outdated
Comment thread crates/modelardb_storage/src/data_folder/mod.rs
@CGodiksen CGodiksen requested a review from chrthomsen July 1, 2026 06:47
Comment thread crates/modelardb_embedded/src/capi.rs Outdated
Comment thread crates/modelardb_storage/src/parser.rs
@skejserjensen skejserjensen self-requested a review July 2, 2026 13:42
Comment thread crates/modelardb_embedded/bindings/python/tests/test_operations.py
Comment thread crates/modelardb_embedded/src/operations/data_folder.rs
Comment thread crates/modelardb_embedded/src/operations/data_folder.rs
@CGodiksen CGodiksen requested a review from skejserjensen July 3, 2026 04:58
@CGodiksen CGodiksen merged commit ef0e531 into main Jul 3, 2026
5 checks passed
@CGodiksen CGodiksen deleted the dev/manual-optimize branch July 3, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for using Delta Lake vacuum() and Delta Lake optimize() through Arrow Flight

4 participants