feat(python): index config repr method (#1509)

PR fixes #1506
This commit is contained in:
Gagan Bhullar
2024-08-07 09:46:46 -06:00
committed by GitHub
parent e01045692c
commit d5a01ffe7b
2 changed files with 8 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ async def test_create_scalar_index(some_table: AsyncTable):
# Can recreate if replace=True
await some_table.create_index("id", replace=True)
indices = await some_table.list_indices()
assert str(indices) == '[Index(BTree, columns=["id"])]'
assert len(indices) == 1
assert indices[0].index_type == "BTree"
assert indices[0].columns == ["id"]

View File

@@ -98,6 +98,13 @@ pub struct IndexConfig {
pub columns: Vec<String>,
}
#[pymethods]
impl IndexConfig {
pub fn __repr__(&self) -> String {
format!("Index({}, columns={:?})", self.index_type, self.columns)
}
}
impl From<lancedb::index::IndexConfig> for IndexConfig {
fn from(value: lancedb::index::IndexConfig) -> Self {
let index_type = format!("{:?}", value.index_type);