From f038cbcb7bf89f1c9b5df96157f26632c3b59956 Mon Sep 17 00:00:00 2001 From: Taewoon Kim Date: Mon, 23 Nov 2026 11:06:06 +0900 Subject: [PATCH] Facets test: compare what the two results count, not the facet source, which is index or scan (closes #461) --- tests/test_result_set_facets.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/test_result_set_facets.py b/tests/test_result_set_facets.py index 7918d23d..e5172e29 100644 --- a/tests/test_result_set_facets.py +++ b/tests/test_result_set_facets.py @@ -405,10 +405,18 @@ def test_facets_first_give_the_same_facets(self, test_db): assert rs.facets == facets rows_first = test_db.query("sql", TERMS_Q) rows_first.to_list() - # meta is how far the projection lagged, which can differ between two runs - assert {k: v for k, v in facets.items() if k != "meta"} == { - k: v for k, v in rows_first.facets.items() if k != "meta" - } + + # meta is how far the projection lagged, which can differ between two runs, and so can the source of a facet: `index` once the + # projection has caught up, `scan` before (both are correct answers, see "source" in the facets guide), so the two runs are + # compared on what they count (#461) + def counted(result): + return { + k: {name: value for name, value in facet.items() if name != "source"} + for k, facet in result.items() + if k != "meta" + } + + assert counted(facets) == counted(rows_first.facets) def test_facets_of_a_lazy_command_cursor(self, test_db): _docs(test_db)