Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1332 +/- ##
==========================================
- Coverage 91.77% 91.77% -0.01%
==========================================
Files 53 53
Lines 8401 8388 -13
==========================================
- Hits 7710 7698 -12
+ Misses 691 690 -1
🚀 New features to boost your workflow:
|
jan-glx
force-pushed
the
refactor/join-masking-without-none
branch
from
November 23, 2026 16:33
7476201 to
477e594
Compare
jan-glx
added a commit
that referenced
this pull request
Nov 23, 2026
…ing matched (#1312) 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: - points with an `inner` or `right` join (`match_rows="no"` or `"left"`): `KeyError: None`, because `_get_masked_element` passed `None` to `.loc` for dask frames - `inner` join with `match_rows="left"`: no error, but the element kept **all** its rows next to a 0-row table - `inner` or `right` join with `match_rows="right"`: `IndexError` from `.iloc[0]` on the empty merge in `_match_rows` This is the minimal fix, three changes in `relational_query.py`: - `_get_masked_element` skips `_match_rows` when no table row matches - for dask frames it falls back to `[]` when no table row matches, like it already did for shapes - `_match_rows` returns empty indices for an empty merge (the inner join calls it again with the already emptied element) The docstring of `join_spatialelement_table` now says what comes back when nothing matches: an empty element or a 0-row table. `None` is only returned for the side an exclusive join never returns (the table for `left_exclusive`, the elements for `right_exclusive`), so the return type depends on `how`, not on the data. The new test runs every `how` × `match_rows` combination for shapes, points and labels against a table that shares no instance with the element; 9 of the shapes and points cases fail on `main`. Labels with an `inner` join 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.
_get_masked_element no longer uses None as a marker for "no table row matches"; an empty array goes through the normal path. With match_rows, the element rows to keep are the merge rows that have a table row (right_index.notna()), which replaces the length shortcut and the isin filter. _match_rows returns the merge result as is. The empty-merge guard is no longer needed, and the .iloc[0] NaN check was dead code: the background label is dropped before the merge and the left join drops NaN indices afterwards.
jan-glx
force-pushed
the
refactor/join-masking-without-none
branch
from
November 23, 2026 16:38
7168520 to
634ebe0
Compare
jan-glx
marked this pull request as ready for review
November 23, 2026 16:48
This branch has not been deployed
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.
TLDR: simplify code, avoid bugs
#1312 fixed #1226 with the smallest change, which adds special cases for "nothing matches" to the join code. This PR removes them, along with older ones, without changing behaviour:
_get_masked_elementno longer usesNoneas a marker for "no table row matches". An empty array goes through the normal path, so.locno longer needs aNonefallback for shapes or points. Withmatch_rows, the element rows to keep are the merge rows that have a table row (right_index.notna()). This replaces the length shortcut and theisinfilter._match_rowsreturns the merge result as is. The empty-merge guard from fix: inner and right joins crashed or kept all element rows when nothing matched #1312 is no longer needed, and the.iloc[0]NaN check was dead code: the background label is dropped before the merge, and the left join drops NaN indices afterwards.The tests from #1312 cover the no-match case for every
how×match_rowscombination and pass unchanged, as does the full suite.The new asv benchmark
TimeJoinstimesjoin_spatialelement_tableon 200k instances, for the cases that go through the changed code. Results on a 16-core Linux server (Python 3.13), withmainand this PR run alternately five times and the samples pooled (mean ± spread); asv marks none of the differences as significant:mainRun it with
asv run --python=same -b TimeJoins(about 20 s).