feat(python): optimize stats repr method (#1510)

PR fixes #1507
This commit is contained in:
Gagan Bhullar
2024-08-07 09:47:52 -06:00
committed by GitHub
parent d5a01ffe7b
commit 32123713fd
2 changed files with 13 additions and 0 deletions

View File

@@ -1034,6 +1034,12 @@ async def test_optimize(db_async: AsyncConnection):
],
)
stats = await table.optimize()
expected = (
"OptimizeStats(compaction=CompactionStats { fragments_removed: 2, "
"fragments_added: 1, files_removed: 2, files_added: 1 }, "
"prune=RemovalStats { bytes_removed: 0, old_versions_removed: 0 })"
)
assert str(stats) == expected
assert stats.compaction.files_removed == 2
assert stats.compaction.files_added == 1
assert stats.compaction.fragments_added == 1

View File

@@ -60,6 +60,13 @@ pub struct Table {
inner: Option<LanceDbTable>,
}
#[pymethods]
impl OptimizeStats {
pub fn __repr__(&self) -> String {
format!("OptimizeStats(compaction={:?}, prune={:?})", self.compaction, self.prune)
}
}
impl Table {
pub(crate) fn new(inner: LanceDbTable) -> Self {
Self {