mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-13 14:16:54 +00:00
fix(python): resolve the single vector column despite a query dimension mismatch (#4526)
\`inf_vector_column_query\`'s \`dim\` filter (added in #3423) is meant to disambiguate between multiple vector columns of different sizes. When a schema has exactly one vector column and the query's dimension doesn't match it, the filter excluded that column too, raising "There is no vector column in the data" instead of resolving the column and letting the dimension mismatch surface at query execution. This was latent until #4409 wired client-side vector-column inference into remote search: a mismatched-dimension query against a single-vector-column remote table now fails client-side with the wrong error, before ever reaching the server's own dimension validation. Fall back to the unfiltered candidate set when the dimension filter leaves zero matches, and only raise when that is still ambiguous or genuinely empty.
This commit is contained in:
@@ -4016,6 +4016,26 @@ def test_search_nested_vector_no_candidates(mem_db: DBConnection):
|
||||
table.search([0.0, 1.0]).limit(1).to_arrow()
|
||||
|
||||
|
||||
def test_search_single_vector_column_wrong_query_dim(mem_db: DBConnection):
|
||||
"""A query vector whose dimension doesn't match the (only) vector column
|
||||
must still resolve that column, surfacing a dimension-mismatch error from
|
||||
query execution rather than a misleading "no vector column" error."""
|
||||
schema = pa.schema(
|
||||
[
|
||||
pa.field("id", pa.uint32(), False),
|
||||
pa.field("vector_col", pa.list_(pa.float32(), 32), False),
|
||||
]
|
||||
)
|
||||
table = mem_db.create_table(
|
||||
"wrong_query_dim",
|
||||
data=[{"id": 1, "vector_col": [0.1] * 32}],
|
||||
schema=schema,
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match="dim"):
|
||||
table.search([0.01] * 120).limit(1).to_arrow()
|
||||
|
||||
|
||||
def test_compact_cleanup(tmp_db: DBConnection):
|
||||
pytest.importorskip("lance")
|
||||
table = tmp_db.create_table(
|
||||
|
||||
Reference in New Issue
Block a user