Skip to content

Add parser of simplified sparql#9

Open
VanyaGlazunov wants to merge 1 commit intomainfrom
feat-simple-sparql-querries
Open

Add parser of simplified sparql#9
VanyaGlazunov wants to merge 1 commit intomainfrom
feat-simple-sparql-querries

Conversation

@VanyaGlazunov
Copy link
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
Collaborator Author

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

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

1 participant