Repository navigation
fix: left join with no matching rows crashed queries on labels - #1266
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1266 +/- ##
=======================================
Coverage 91.43% 91.43%
=======================================
Files 53 53
Lines 8395 8395
=======================================
Hits 7676 7676
Misses 719 719
🚀 New features to boost your workflow:
|
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.
5377b7f to
d426a63
Compare
|
(sorry for the rebase) Thanks for tracking this down, and for the test that builds the case on purpose. I'd fix it one level down, though. The def _region_as_str_if_list_of_len_one(region: list[str]) -> str | list[str]:
return region[0] if len(region) == 1 else regiona single region is still stored as a string (the released behaviour #1160 restored), and the left join returns a 0-row table with
I tried this together with your test on a branch, and the query and operations tests seemed happy with it. Feel free to take it over into this PR if it makes sense to you, or I'm happy to push it here myself. This is also the bug in #1226 (left join part), and the cause of the flaky |
A left join with no matching rows now returns an empty table with region set to [], as the docstring and the storage spec describe, rather than None. This also covers the exclusive and right joins, which use the same helper. Co-authored-by: Jan Gleixner <[email protected]>
|
Thanks, that makes sense, the helper is the better place for it. I've taken your change over on top and kept the test. Query and operations tests pass locally. I also updated the description and linked #1226. |
There was a problem hiding this comment.
@LucaMarconato could you have a look? This also fixes the flaky test_attributes_are_copied[labels2d-*] in the pre-release job, so it is on the release list.
Querying a labels element that is annotated by a table, but whose cropped area contains none of the annotated instances, crashes
polygon_queryandbounding_box_querywithIndexError: list index out of rangein_region_as_str_if_list_of_len_one, which reads the first element of an empty region list.The helper now only unwraps a list of length one. A left join with no matching rows returns an empty table with
region == [], as the docstring and the storage format spec describe, and the query callers already drop empty tables, so the query keeps the labels and drops the table. The exclusive and right joins use the same helper, so they're covered too. Thanks to @jan-glx for the suggestion.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 sharedRNGinconftest.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.Also addresses the left join part of #1226.