Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing SPARQL request to retrieve all statements from one or more specific graphs #5245

Open
aindlq opened this issue Feb 4, 2025 · 0 comments
Labels
🐞 bug issue is a bug

Comments

@aindlq
Copy link

aindlq commented Feb 4, 2025

Current Behavior

When getting all statements from a given graph with connection.getStatemnts(null, null, null, ctx) for SPARQLConnection, it uses the following query:

private static final String EVERYTHING_WITH_GRAPH = "SELECT * WHERE {  ?s ?p ?o . OPTIONAL { GRAPH ?ctx { ?s ?p ?o } } }";

The actual context is propagated through HTTP query param default-graph-uri which is equivalent to FROM in SPARQL query. As I understand, according to SPARQL standard if FROM is specified, but FROM NAMED is not, then there will be no graphs to match with GRAPH:

Each FROM clause contains an IRI that indicates a graph to be used to form the default graph. This does not put the graph in as a named graph.

As a result projected ?ctx is always empty.

I guess in addition to setting default-graph-uri setBindings should also set named-graph-uri. See https://github.com/eclipse-rdf4j/rdf4j/blob/main/core/repository/sparql/src/main/java/org/eclipse/rdf4j/repository/sparql/SPARQLConnection.java#L786

Or probably it makes sense to use different base queries. The existing query works fine when contexts are not provided. When contexts are specified, something like SELECT * WHERE { GRAPH ?ctx { ?s ?p ?o }} together with named-graph-uri would be more correct.

Expected Behavior

Steps To Reproduce

No response

Version

5.1.0

Are you interested in contributing a solution yourself?

None

Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug issue is a bug
Projects
None yet
Development

No branches or pull requests

1 participant