From 6416840c33fc7a2c7ff805210ab5f7161bf771c8 Mon Sep 17 00:00:00 2001 From: Jack Ye Date: Wed, 15 Jul 2026 23:08:58 -0700 Subject: [PATCH] test: update python expectations for lance 9.1 --- python/python/lancedb/query.py | 22 +++++++++++----------- python/python/tests/test_permutation.py | 17 +++++++++++++---- python/python/tests/test_query.py | 8 ++++---- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/python/python/lancedb/query.py b/python/python/lancedb/query.py index 49e3a171e..ff48541e3 100644 --- a/python/python/lancedb/query.py +++ b/python/python/lancedb/query.py @@ -3875,18 +3875,18 @@ class AsyncHybridQuery(AsyncStandardQuery, AsyncVectorQueryBase): >>> asyncio.run(doctest_example()) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE RRFReranker(K=60) ProjectionExec: expr=[vector@0 as vector, text@3 as text, _distance@2 as _distance] - Take: columns="vector, _rowid, _distance, (text)" - CoalesceBatchesExec: target_batch_size=1024 - GlobalLimitExec: skip=0, fetch=10 - FilterExec: _distance@2 IS NOT NULL - SortExec: TopK(fetch=10), expr=[_distance@2 ASC NULLS LAST, _rowid@1 ASC NULLS LAST], preserve_partitioning=[false] - KNNVectorDistance: metric=l2 - LanceRead: uri=..., projection=[vector], ... + Take: columns="vector, _rowid, _distance, (text)" + CoalesceBatchesExec: target_batch_size=1024 + GlobalLimitExec: skip=0, fetch=10 + FilterExec: _distance@2 IS NOT NULL + SortExec: TopK(fetch=10), expr=[_distance@2 ASC NULLS LAST, _rowid@1 ASC NULLS LAST], preserve_partitioning=[false] + KNNVectorDistance: metric=l2 + LanceRead: uri=..., projection=[vector], ... ProjectionExec: expr=[vector@2 as vector, text@3 as text, _score@1 as _score] - Take: columns="_rowid, _score, (vector), (text)" - CoalesceBatchesExec: target_batch_size=1024 - GlobalLimitExec: skip=0, fetch=10 - MatchQuery: column=text, query=hello + Take: columns="_rowid, _score, (vector), (text)" + CoalesceBatchesExec: target_batch_size=1024 + GlobalLimitExec: skip=0, fetch=10 + MatchQuery: column=text, query=[hello] Parameters ---------- diff --git a/python/python/tests/test_permutation.py b/python/python/tests/test_permutation.py index 7ff35e5e2..a9bcae730 100644 --- a/python/python/tests/test_permutation.py +++ b/python/python/tests/test_permutation.py @@ -128,9 +128,16 @@ def test_split_hash(mem_db): def test_split_hash_with_discard(mem_db): """Test hash-based splitting with discard weight.""" + total_rows = 1000 tbl = mem_db.create_table( "test_table", - pa.table({"id": range(100), "category": ["A", "B"] * 50, "value": range(100)}), + pa.table( + { + "id": range(total_rows), + "category": [f"category-{i}" for i in range(total_rows)], + "value": range(total_rows), + } + ), ) permutation_tbl = ( @@ -142,10 +149,12 @@ def test_split_hash_with_discard(mem_db): .execute() ) - # Should have fewer than 100 rows due to discard + # Should have fewer rows due to discard, but should not be empty. row_count = permutation_tbl.count_rows() - assert row_count < 100 - assert row_count > 0 # But not empty + assert 0 < row_count < total_rows + + data = permutation_tbl.search(None).to_arrow().to_pydict() + assert set(data["split_id"]) == {0, 1} def test_split_sequential(mem_db): diff --git a/python/python/tests/test_query.py b/python/python/tests/test_query.py index 62ee6e1eb..6840be052 100644 --- a/python/python/tests/test_query.py +++ b/python/python/tests/test_query.py @@ -1273,7 +1273,7 @@ async def test_explain_plan_fts(table_async: AsyncTable): query = await table_async.search("dog", query_type="fts", fts_columns="text") plan = await query.explain_plan() # Should show FTS details (issue #2465 is now fixed) - assert "MatchQuery: column=text, query=dog" in plan + assert "MatchQuery: column=text, query=[dog]" in plan assert "GlobalLimitExec" in plan # Default limit # Test FTS query with limit @@ -1281,7 +1281,7 @@ async def test_explain_plan_fts(table_async: AsyncTable): "dog", query_type="fts", fts_columns="text" ) plan_with_limit = await query_with_limit.limit(1).explain_plan() - assert "MatchQuery: column=text, query=dog" in plan_with_limit + assert "MatchQuery: column=text, query=[dog]" in plan_with_limit assert "GlobalLimitExec: skip=0, fetch=1" in plan_with_limit # Test FTS query with offset and limit @@ -1289,7 +1289,7 @@ async def test_explain_plan_fts(table_async: AsyncTable): "dog", query_type="fts", fts_columns="text" ) plan_with_offset = await query_with_offset.offset(1).limit(1).explain_plan() - assert "MatchQuery: column=text, query=dog" in plan_with_offset + assert "MatchQuery: column=text, query=[dog]" in plan_with_offset assert "GlobalLimitExec: skip=1, fetch=1" in plan_with_offset @@ -1333,7 +1333,7 @@ async def test_explain_plan_with_filters(table_async: AsyncTable): "dog", query_type="fts", fts_columns="text" ) plan_fts_filter = await query_fts_filter.where("id = 1").explain_plan() - assert "MatchQuery: column=text, query=dog" in plan_fts_filter + assert "MatchQuery: column=text, query=[dog]" in plan_fts_filter assert "LanceRead" in plan_fts_filter assert "full_filter=id = Int64(1)" in plan_fts_filter # Should show filter details