feat(python): add delete unverified parameter (#1542)

PR fixes #1527
This commit is contained in:
Gagan Bhullar
2024-08-15 10:01:32 -06:00
committed by GitHub
parent b624fc59eb
commit 20faa4424b
3 changed files with 35 additions and 3 deletions

View File

@@ -8,6 +8,7 @@ from pathlib import Path
from time import sleep
from typing import List
from unittest.mock import PropertyMock, patch
import os
import lance
import lancedb
@@ -1052,3 +1053,25 @@ async def test_optimize(db_async: AsyncConnection):
assert stats.prune.old_versions_removed == 3
assert await table.query().to_arrow() == pa.table({"x": [[1], [2]]})
@pytest.mark.asyncio
async def test_optimize_delete_unverified(db_async: AsyncConnection, tmp_path):
table = await db_async.create_table(
"test",
data=[{"x": [1]}],
)
await table.add(
data=[
{"x": [2]},
],
)
version = await table.version()
path = tmp_path / "test.lance" / "_versions" / f"{version - 1}.manifest"
os.remove(path)
stats = await table.optimize(delete_unverified=False)
assert stats.prune.old_versions_removed == 0
stats = await table.optimize(
cleanup_older_than=timedelta(seconds=0), delete_unverified=True
)
assert stats.prune.old_versions_removed == 2