Skip to content

fix(spatial): keep a property path joined through its blank node - #53

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 18, 2026 •

Copy link
Copy Markdown
Contributor

Closes #48.

Cause

The parser writes ?x (a|b/c)/geo:asWKT ?p as two parts: a path from ?x to 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 spatial FILTER on ?p then 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 BIND form, which the rewrite doesn't touch.

Fix

cost::names gives 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 <, and sfContains the 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).

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
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.

FILTER(geof:sfWithin) with an alternative property path returns every row, including points outside

1 participant