mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-28 13:33:59 +00:00
fix: preserve index names and isolate unsafe legacy listings
This commit is contained in:
@@ -1953,9 +1953,7 @@ class Table(ABC):
|
||||
LanceDB Enterprise only: how long to wait for the index build to finish.
|
||||
If not set, the call returns once the build is scheduled.
|
||||
name : str, optional
|
||||
Custom name for the index: 1–128 ASCII letters, digits, dashes,
|
||||
underscores, or periods, excluding ``.`` and ``..``. If omitted,
|
||||
a default name is generated from the column name.
|
||||
Custom name for the index.
|
||||
train : bool, default True
|
||||
Whether to train the index with existing data.
|
||||
|
||||
@@ -2121,8 +2119,6 @@ class Table(ABC):
|
||||
The timeout to wait if indexing is asynchronous.
|
||||
name: str, optional
|
||||
The name of the index. If not provided, a default name will be generated.
|
||||
Custom names must contain 1–128 ASCII letters, digits, dashes,
|
||||
underscores, or periods, excluding ``.`` and ``..``.
|
||||
Examples
|
||||
--------
|
||||
|
||||
@@ -2282,8 +2278,6 @@ class Table(ABC):
|
||||
The timeout to wait if indexing is asynchronous.
|
||||
name: str, optional
|
||||
The name of the index. If not provided, a default name will be generated.
|
||||
Custom names must contain 1–128 ASCII letters, digits, dashes,
|
||||
underscores, or periods, excluding ``.`` and ``..``.
|
||||
|
||||
Notes
|
||||
-----
|
||||
@@ -3096,6 +3090,10 @@ class Table(ABC):
|
||||
List all indices that have been created with
|
||||
[Table.create_index][lancedb.table.Table.create_index]
|
||||
|
||||
On older Enterprise servers, this method omits indices named ``.``,
|
||||
``..`` or the empty string because their statistics cannot be requested
|
||||
safely.
|
||||
|
||||
On LanceDB Enterprise tables, an index whose build hasn't finished may
|
||||
be missing (vector indices) or listed with 0 indexed rows (scalar and
|
||||
FTS indices), and ``num_unindexed_rows`` may be ``None``. Use
|
||||
@@ -4456,9 +4454,7 @@ class LanceTable(Table):
|
||||
wait_timeout : timedelta, optional
|
||||
Timeout to wait for async indexing to complete.
|
||||
name : str, optional
|
||||
Custom name for the index: 1–128 ASCII letters, digits, dashes,
|
||||
underscores, or periods, excluding ``.`` and ``..``. If omitted,
|
||||
a default name is generated from the column name.
|
||||
Custom name for the index.
|
||||
train : bool, default True
|
||||
Whether to train the index with existing data.
|
||||
|
||||
@@ -6906,8 +6902,6 @@ class AsyncTable:
|
||||
If not set, the call returns once the build is scheduled.
|
||||
name: str, optional
|
||||
The name of the index. If not provided, a default name will be generated.
|
||||
Custom names must contain 1–128 ASCII letters, digits, dashes,
|
||||
underscores, or periods, excluding ``.`` and ``..``.
|
||||
exist_ok: bool, default False
|
||||
Preserve an existing index with the requested or derived name. This
|
||||
takes precedence over replace and keeps its definition and build.
|
||||
@@ -8926,6 +8920,10 @@ class AsyncTable:
|
||||
"""
|
||||
List all indices that have been created with Self::create_index
|
||||
|
||||
On older Enterprise servers, this method omits indices named ``.``,
|
||||
``..`` or the empty string because their statistics cannot be requested
|
||||
safely.
|
||||
|
||||
On LanceDB Enterprise tables, an index whose build hasn't finished may
|
||||
be missing (vector indices) or listed with 0 indexed rows (scalar and
|
||||
FTS indices), and ``num_unindexed_rows`` may be ``None``. Use
|
||||
|
||||
@@ -663,3 +663,27 @@ async def test_named_index_exist_ok_checks_before_column_validation(
|
||||
await result.wait()
|
||||
assert await some_table.version() == version
|
||||
assert [index.name for index in await some_table.list_indices()] == ["kept"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("name", ["Customer lookup", "café_idx"])
|
||||
@pytest.mark.parametrize("background", [False, True])
|
||||
async def test_custom_index_names_preserve_exist_ok(some_table, name, background):
|
||||
method = some_table.create_index_async if background else some_table.create_index
|
||||
job = await method("id", config=BTree(), name=name, exist_ok=True)
|
||||
if background:
|
||||
await job.wait()
|
||||
version = await some_table.version()
|
||||
original = await some_table.list_indices()
|
||||
# A second call keeps the existing definition and version.
|
||||
job = await method("id", config=Bitmap(), name=name, exist_ok=True)
|
||||
if background:
|
||||
await job.wait()
|
||||
assert await some_table.version() == version
|
||||
indices = await some_table.list_indices()
|
||||
assert len(indices) == 1
|
||||
assert indices[0].name == name
|
||||
assert indices[0].index_type == original[0].index_type == "BTree"
|
||||
assert (await some_table.index_stats(name)).num_indexed_rows == NROWS
|
||||
await some_table.drop_index(name)
|
||||
assert await some_table.list_indices() == []
|
||||
|
||||
Reference in New Issue
Block a user