-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add optimize command in python binding (#1313)
# Description This is a implementation of the Optimize Command for python binding. # Related Issue(s) #622 --------- Co-authored-by: dengkai02 <dengkai02@appledeMacBook-Pro-3.local>
- Loading branch information
Showing
4 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pathlib | ||
|
||
import pyarrow as pa | ||
import pytest | ||
|
||
from deltalake import DeltaTable, write_deltalake | ||
|
||
|
||
@pytest.mark.parametrize("use_relative", [True, False]) | ||
def test_optimize_run_table( | ||
tmp_path: pathlib.Path, sample_data: pa.Table, monkeypatch, use_relative: bool | ||
): | ||
if use_relative: | ||
monkeypatch.chdir(tmp_path) # Make tmp_path the working directory | ||
(tmp_path / "path/to/table").mkdir(parents=True) | ||
table_path = "./path/to/table" | ||
else: | ||
table_path = str(tmp_path) | ||
|
||
write_deltalake(table_path, sample_data, mode="append") | ||
write_deltalake(table_path, sample_data, mode="append") | ||
write_deltalake(table_path, sample_data, mode="append") | ||
|
||
dt = DeltaTable(table_path) | ||
dt.optimize() | ||
last_action = dt.history(1)[0] | ||
assert last_action["operation"] == "OPTIMIZE" |