lancedb/lancedb · error · ValueError
vector_results should be a list of pa.Table or…
Error message
vector_results should be a list of pa.Table or LanceVectorQueryBuilder
What it means
After normalizing LanceVectorQueryBuilder inputs, rerank_multivector validates that each element is a pyarrow Table. Any element that is neither a query builder nor a pa.Table (e.g. a list of dicts or a pandas DataFrame) cannot be reranked, so ValueError is raised.
Solutions
- Convert inputs to pyarrow Tables before reranking: pa.Table.from_pandas(df) or call .to_arrow() on the query builder.
- Only pass results produced by vector search .with_row_id(True).to_arrow() (or the builders themselves).
- Validate with all(isinstance(v, pa.Table) for v in vector_results) before the call.
Example fix
// before reranker.rerank_multivector(query, [df1, df2]) // after import pyarrow as pa reranker.rerank_multivector(query, [pa.Table.from_pandas(df1), pa.Table.from_pandas(df2)])
Defensive patterns
Strategy: validation
Validate before calling
if not all(isinstance(v, pa.Table) for v in vector_results):
raise TypeError('each vector result must be a pyarrow Table') Type guard
def is_pyarrow_table(v):
return isinstance(v, pa.Table) Try / catch
try:
ranked = reranker.rerank_multivector(query, vector_results)
except ValueError:
vector_results = [v if isinstance(v, pa.Table) else pa.Table.from_pandas(v) for v in vector_results]
ranked = reranker.rerank_multivector(query, vector_results) Prevention
- Convert pandas/DataFrame intermediates back to pa.Table before reranking
- Only feed rerankers with outputs of vector_search(...).to_arrow()
- Pin and document expected types at pipeline boundaries
When it happens
Trigger: Passing items like pandas DataFrames, dicts, or LanceDB query results wrapped in another container as vector_results elements, when the first element also isn't a LanceVectorQueryBuilder.
Common situations: Converting Arrow results to pandas for preprocessing and then passing them back to the reranker; passing raw query response objects from a different API version.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- vector_results should be a list of pa.Table or…
- All elements in vector_results should be of the same type
- All elements in vector_results should be of the same type
- All elements in vector_results should be of the same type
- rerank_hybrid must return a pyarrow.Table, got
AI-assisted analysis of lancedb/lancedb@c7b051aff7 (2026-09-08).
Data as JSON: /api/errors/7cdb6e9dd23bf232.
Report an issue: GitHub.
Appendix: source
Thrown at python/python/lancedb/rerankers/mrr.py:140
Reranks the results from multiple vector searches using MRR algorithm.
Each vector search result is treated as a separate ranking system,
and MRR calculates the mean of reciprocal ranks across all systems.
This cannot reuse rerank_hybrid because MRR semantics require treating
each vector result as a separate ranking system.
"""
if not vector_results:
raise ValueError("vector_results must not be empty")
if not all(isinstance(v, type(vector_results[0])) for v in vector_results):
raise ValueError(
"All elements in vector_results should be of the same type"
)
# avoid circular import
if type(vector_results[0]).__name__ == "LanceVectorQueryBuilder":
vector_results = [result.to_arrow() for result in vector_results]
elif not isinstance(vector_results[0], pa.Table):
raise ValueError(
"vector_results should be a list of pa.Table or LanceVectorQueryBuilder"
)
if not all("_rowid" in result.column_names for result in vector_results):
raise ValueError(
"'_rowid' is required for deduplication. \
add _rowid to search results like this: \
`search().with_row_id(True)`"
)
mrr_score_map = defaultdict(list)
for result_table in vector_results:
result_ids = result_table["_rowid"].to_pylist()
for rank, result_id in enumerate(result_ids, 1):
reciprocal_rank = 1.0 / rank
mrr_score_map[result_id].append(reciprocal_rank)
View on GitHub (pinned to c7b051aff7)