Skip to content

fix(spatial): keep a path joined to a relation triple through its blank node - #55

Merged
MathiasVDA merged 1 commit into
mainfrom
claude/project-thread-n3oul3
Nov 19, 2026
Merged

MathiasVDA merged 1 commit into
mainfrom
claude/project-thread-n3oul3

Conversation

@MathiasVDA

@MathiasVDA MathiasVDA commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #54 (follow-up to #48 / #53).

Cause

The parser joins ?x (a|b)/geo:hasGeometry ?g as 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 with DISTINCT of 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. A SELECT projects its own variables, so they are not returned; the test checks that with SELECT *.

Tests

tests/spatial_paths.rs gains 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).

…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
@MathiasVDA
MathiasVDA merged commit b75e5bf into main Nov 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GeoSPARQL relation triple after a path ending in a blank node returns every geometry for every row

1 participant