Repository navigation
fix(spatial): keep a path joined to a relation triple through its blank node - #55
Merged
Merged
Conversation
…nk node The parser joins `?x (a|b)/geo:hasGeometry ?g` as a path to a blank node and the triple `_:b geo:hasGeometry ?g`. When that BGP also holds a relation triple (`?g geo:sfWithin ?rg`), the spatial rewrite turns it into a projection of its variables, which dropped the blank node: every geometry matched every row. The blank nodes linking a path to its siblings are now written as variables before the rewrite. Closes #54
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 #54 (follow-up to #48 / #53).
Cause
The parser joins
?x (a|b)/geo:hasGeometry ?gas a path to a blank node, plus the triple_:b geo:hasGeometry ?g. When that BGP also holds a relation triple such as?g geo:sfWithin ?rg, the spatial rewrite replaces it withDISTINCTof a projection of its variables. The projection dropped_:b, so the path no longer joined to it, and every geometry matched every row (7,611,400 rows instead of 1,056 on the review probe).Fix
Before a join is rewritten, the blank nodes at the ends of its property paths are written as variables named
__tt_path_<label>, both in the paths and in the sibling BGPs. The projection then keeps them. ASELECTprojects its own variables, so they are not returned; the test checks that withSELECT *.Tests
tests/spatial_paths.rsgains a test of the property form. It covers 5 paths ((ref|part)/,ref?/,part*/,part+/,(part/part?)?/) × 3 relations (sfWithin,sfIntersects,ehInside). The reference is the same query with the path's end written as?m, because the evaluator alone infers no relation triples. The test fails without the fix.The spatial crate's tests, the tripletrail spatial test files and the lib tests pass. fmt and clippy are clean.
Docs
CHANGELOG (Fixed).