Skip to content

fix: left join with no matching rows crashed queries on labels - #1266

Open
FarisHrvat wants to merge 1 commit into
scverse:mainfrom
FarisHrvat:fix-left-join-no-match
Open

FarisHrvat wants to merge 1 commit into
scverse:mainfrom
FarisHrvat:fix-left-join-no-match

Conversation

@FarisHrvat

@FarisHrvat FarisHrvat commented Sep 29, 2026 •

Copy link
Copy Markdown

Querying a labels element that is annotated by a table, but whose cropped area contains none of the annotated instances, crashes polygon_query and bounding_box_query with IndexError: list index out of range in _region_as_str_if_list_of_len_one. The left join builds a 0-row table and then reads the first element of an empty region list.
This now returns no table in that case, like the inner and exclusive joins already do, so the query keeps the labels and drops the table.
It's also the random failure of test_attributes_are_copied[labels2d-*] in the pre-release job on #1265. The labels there come from the shared RNG in conftest.py, so whether the small query box contains an annotated instance depends on which tests ran before on the same worker. Added a test that builds that case on purpose.

When a queried labels element is annotated by a table but none of its
remaining instances are in the table, the left join built a 0-row table and
_region_as_str_if_list_of_len_one crashed on the empty region list. Return
no table in that case, like the inner and exclusive joins already do.

This is the random IndexError in test_attributes_are_copied[labels2d]: the
labels come from the shared RNG in conftest, so whether the tiny query box
contains an annotated instance depends on test order.
@codecov

codecov Bot commented Sep 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.40%. Comparing base (ea93a37) to head (5377b7f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1266   +/-   ##
=======================================
  Coverage   91.40%   91.40%           
=======================================
  Files          53       53           
  Lines        8381     8381           
=======================================
  Hits         7661     7661           
  Misses        720      720           
Files with missing lines Coverage Δ
src/spatialdata/_core/query/relational_query.py 93.34% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant