Repository navigation
fix: inner and right joins crashed or kept all element rows when nothing matched - #1312
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1312 +/- ##
==========================================
+ Coverage 91.71% 91.77% +0.06%
==========================================
Files 53 53
Lines 8399 8401 +2
==========================================
+ Hits 7703 7710 +7
+ Misses 696 691 -5
🚀 New features to boost your workflow:
|
…ing matched When the element and the table share no instance, three joins broke: - points with inner/right (match_rows "no"/"left"): KeyError: None, because _get_masked_element passed None to .loc for dask frames - inner with match_rows="left": the element kept all its rows next to a 0-row table - inner/right with match_rows="right": IndexError from .iloc[0] on the empty merge in _match_rows _get_masked_element now skips _match_rows when no table row matches and falls back to [] for dask frames like it already did for shapes, and _match_rows returns empty indices for an empty merge. The docstring of join_spatialelement_table now says that an empty result is an empty element or a 0-row table; None is only returned for the side an exclusive join never returns. Closes scverse#1226.
jan-glx
force-pushed
the
fix/1226-inner-right-empty-join
branch
from
November 23, 2026 15:27
accbe4d to
e168b5b
Compare
jan-glx
marked this pull request as ready for review
November 23, 2026 16:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #1226.
#1266 fixed the left join when the element and the table share no instance. The other join types still broke in that case:
innerorrightjoin (match_rows="no"or"left"):KeyError: None, because_get_masked_elementpassedNoneto.locfor dask framesinnerjoin withmatch_rows="left": no error, but the element kept all its rows next to a 0-row tableinnerorrightjoin withmatch_rows="right":IndexErrorfrom.iloc[0]on the empty merge in_match_rowsThis is the minimal fix, three changes in
relational_query.py:_get_masked_elementskips_match_rowswhen no table row matches[]when no table row matches, like it already did for shapes_match_rowsreturns empty indices for an empty merge (the inner join calls it again with the already emptied element)The docstring of
join_spatialelement_tablenow says what comes back when nothing matches: an empty element or a 0-row table.Noneis only returned for the side an exclusive join never returns (the table forleft_exclusive, the elements forright_exclusive), so the return type depends onhow, not on the data.The new test runs every
how×match_rowscombination for shapes, points and labels against a table that shares no instance with the element; 9 of the shapes and points cases fail onmain. Labels with aninnerjoin are a strict xfail: inner joins don't collect table rows for labels (documented as unsupported), so they return no table instead of a 0-row one.#1332 removes the special cases this fix adds to.