Fix bug join operation with non-annotating table #864
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is very small (I modified only
src/spatialdata/_core/query/relational_query.py
, the rest is from the new ruff pre-commit).This PR fixes a subtle bug that originated when all the following occurred simultaneously:
This occurred for instance with this code:
This occurred because in the cases above

region
was astr
, not alist[str]
, and therefore, in the screenshot below,the check in the highlighted line, which should fail (because the table is not annotating the element), instead succeeds (because
name
is a substring ofregions
).But
name
is not a valid group ofgroups_df
, which leads to aKeyError
.Solution
The solution is very simple. Still, two observations (CC @melonora):
region
from the metadata Dropregion
(region_key
andinstance_key
are enough) #629 and avoid future technical debts, which occurs as this bug showed.left_exclusive
join #824 (comment). The current PR exemplify the code redundancy.