{"record":{"id":"7cdb6e9dd23bf232","repo":"lancedb/lancedb","slug":"vector-results-should-be-a-list-of-pa-table-or-lan-7cdb6e","errorCode":null,"errorMessage":"vector_results should be a list of pa.Table or LanceVectorQueryBuilder","messagePattern":"vector_results should be a list of pa\\.Table or LanceVectorQueryBuilder","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/python/lancedb/rerankers/mrr.py","lineNumber":140,"sourceCode":"        Reranks the results from multiple vector searches using MRR algorithm.\n        Each vector search result is treated as a separate ranking system,\n        and MRR calculates the mean of reciprocal ranks across all systems.\n        This cannot reuse rerank_hybrid because MRR semantics require treating\n        each vector result as a separate ranking system.\n        \"\"\"\n        if not vector_results:\n            raise ValueError(\"vector_results must not be empty\")\n\n        if not all(isinstance(v, type(vector_results[0])) for v in vector_results):\n            raise ValueError(\n                \"All elements in vector_results should be of the same type\"\n            )\n\n        # avoid circular import\n        if type(vector_results[0]).__name__ == \"LanceVectorQueryBuilder\":\n            vector_results = [result.to_arrow() for result in vector_results]\n        elif not isinstance(vector_results[0], pa.Table):\n            raise ValueError(\n                \"vector_results should be a list of pa.Table or LanceVectorQueryBuilder\"\n            )\n\n        if not all(\"_rowid\" in result.column_names for result in vector_results):\n            raise ValueError(\n                \"'_rowid' is required for deduplication. \\\n                    add _rowid to search results like this: \\\n                    `search().with_row_id(True)`\"\n            )\n\n        mrr_score_map = defaultdict(list)\n\n        for result_table in vector_results:\n            result_ids = result_table[\"_rowid\"].to_pylist()\n            for rank, result_id in enumerate(result_ids, 1):\n                reciprocal_rank = 1.0 / rank\n                mrr_score_map[result_id].append(reciprocal_rank)\n","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/lancedb/lancedb/blob/c7b051aff7039333a3f61b79217246c27676806a/python/python/lancedb/rerankers/mrr.py#L122-L158","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nreranker.rerank_multivector(query, [df1, df2])\n// after\nimport pyarrow as pa\nreranker.rerank_multivector(query, [pa.Table.from_pandas(df1), pa.Table.from_pandas(df2)])","handlingStrategy":"validation","validationCode":"if not all(isinstance(v, pa.Table) for v in vector_results):\n    raise TypeError('each vector result must be a pyarrow Table')","typeGuard":"def is_pyarrow_table(v):\n    return isinstance(v, pa.Table)","tryCatchPattern":"try:\n    ranked = reranker.rerank_multivector(query, vector_results)\nexcept ValueError:\n    vector_results = [v if isinstance(v, pa.Table) else pa.Table.from_pandas(v) for v in vector_results]\n    ranked = reranker.rerank_multivector(query, vector_results)","preventionTips":["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"],"tags":["python","reranker","type-mismatch","pyarrow"],"backgroundTag":"type-mismatch","analyzedSha":"c7b051aff7039333a3f61b79217246c27676806a","analyzedAt":"2026-09-08T23:42:37.579Z","contentChangedAt":"2026-09-08T23:42:37.579Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}