Repository navigation
fix(spatial): keep a property path joined through its blank node - #53
Merged
Merged
Conversation
The parser writes `?x (a|b/c)/geo:asWKT ?p` as a path to a blank node joined with a triple from it. The spatial rewrite counted only in-scope variables as links between join operands, so the triple was split from the path and a spatial FILTER on ?p matched every geometry for every row. A path now shares its blank-node ends as a BGP does. Closes #48
This was referenced Nov 19, 2026
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 #48.
Cause
The parser writes
?x (a|b/c)/geo:asWKT ?pas two parts: a path from?xto a blank node, joined with the triple_:b geo:asWKT ?p. The spatial rewrite splits a pattern into its join operands and keeps together those that share names. For a basic graph pattern it counted blank nodes as names, but for anything else (a path included) it counted only in-scope variables. So the triple was split from its path. A spatialFILTERon?pthen matched every geometry for every row: for the issue's query, 3 points × 3 rows, including the point outside.A plain sequence path is parsed as triples only, which is why it was right. So was the
BINDform, which the rewrite doesn't touch.Fix
cost::namesgives a path's subject and object, blank nodes included, as a BGP's triples do.Tests
New
tests/spatial_paths.rs: a differential test against Oxigraph's store. It covers 7 path shapes (alternative,?,*,+, alternative of predicates, sequence, plain) × 6 spatial tests (sfWithin,sfIntersects,!sfDisjoint, a conjunction,distance <, andsfContainsthe other way round). It also checks the issue's query for exactly a and b. The test fails without the fix. The spatial crate's tests and the tripletrail spatial test files pass; fmt and clippy are clean.Docs
CHANGELOG (Fixed).