Skip to content

Add parser of simplified sparql#9

Merged
VanyaGlazunov merged 1 commit intomainfrom
feat-simple-sparql-querries
Mar 31, 2026
Merged

Add parser of simplified sparql#9
VanyaGlazunov merged 1 commit intomainfrom
feat-simple-sparql-querries

Conversation

@VanyaGlazunov
Copy link
Copy Markdown
Collaborator

@VanyaGlazunov VanyaGlazunov commented Mar 22, 2026

This PR adds SPARQL query parsing capabilities to pathrex using the spargebra crate. We are trying to support SELECT queries with a single triple pattern in the WHERE clause. For example:

 SELECT ?x ?y WHERE { ?x <knows> ?y . }
 SELECT ?x ?y WHERE { ?x <knows>/<likes>* ?y . }
 SELECT ?x WHERE { <http://example.org/alice> <knows>+ ?x . }

spargebra is an excellent crate that provides production ready parser but we have to add some extra processing after we applied their parser.

  1. Query Validation: We validate that the parsed query is a SELECT query (not ASK, CONSTRUCT, or DESCRIBE).

  2. Pattern Extraction: We extract exactly one triple or property path pattern from the WHERE clause. Queries with multiple patterns or complex BGPs are rejected.

  3. Desugaring Sequences: spargebra desugars sequence paths like ?x <a>/<b>/<c> ?y into a chain of BGP triples with intermediate blank nodes. We reconstruct these back into a single PropertyPathExpression::Sequence for our RPQ evaluators.

  4. Subject/Object Validation: We ensure subjects and objects are either variables or named nodes (literals and blank nodes are not supported as they don't make sense for RPQ evaluation).

The pr closes #2

@VanyaGlazunov
Copy link
Copy Markdown
Collaborator Author

Hello @suvorovrain and @georgiy-belyanin can you look at this please

@VanyaGlazunov VanyaGlazunov force-pushed the feat-simple-sparql-querries branch from 5d3c30e to b01eb13 Compare March 31, 2026 08:49
@VanyaGlazunov VanyaGlazunov merged commit 19235fe into main Mar 31, 2026
6 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.

SPARQL query language support

2 participants