-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(python): expose FSCK (repair) operation (#1730)
# Description This PR exposes the FSCK operation as a `repair` method under the `DeltaTable `class. # Related Issue(s) <!--- For example: - closes #106 ---> - closes #1727 --------- Co-authored-by: Will Jones <[email protected]>
- Loading branch information
1 parent
0ad02d4
commit b53b686
Showing
5 changed files
with
75 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,31 @@ | ||
import os | ||
|
||
from deltalake import DeltaTable, write_deltalake | ||
|
||
|
||
def test_repair_with_dry_run(tmp_path, sample_data): | ||
write_deltalake(tmp_path, sample_data, mode="append") | ||
write_deltalake(tmp_path, sample_data, mode="append") | ||
dt = DeltaTable(tmp_path) | ||
os.remove(dt.file_uris()[0]) | ||
|
||
metrics = dt.repair(dry_run=True) | ||
last_action = dt.history(1)[0] | ||
|
||
assert len(metrics["files_removed"]) == 1 | ||
assert metrics["dry_run"] is True | ||
assert last_action["operation"] == "WRITE" | ||
|
||
|
||
def test_repair_wo_dry_run(tmp_path, sample_data): | ||
write_deltalake(tmp_path, sample_data, mode="append") | ||
write_deltalake(tmp_path, sample_data, mode="append") | ||
dt = DeltaTable(tmp_path) | ||
os.remove(dt.file_uris()[0]) | ||
|
||
metrics = dt.repair(dry_run=False) | ||
last_action = dt.history(1)[0] | ||
|
||
assert len(metrics["files_removed"]) == 1 | ||
assert metrics["dry_run"] is False | ||
assert last_action["operation"] == "FSCK" |
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