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

FROM (NAMED) not allowed in SERVICE #85

Open
rubensworks opened this issue Apr 18, 2019 · 3 comments
Open

FROM (NAMED) not allowed in SERVICE #85

rubensworks opened this issue Apr 18, 2019 · 3 comments

Comments

@rubensworks
Copy link
Collaborator

While this is a valid query as far as I know, it is not accepted by the parser:

SELECT * WHERE {
  SERVICE <http://dbpedia.org/sparql> {
    SELECT *
	FROM <http://dbpedia.org>
	WHERE {
	  ?s ?p ?o
    }
  }
}

Error:

Parse error on line 16:
...ql> {    SELECT *	FROM <http://dbpedia
---------------------^
Expecting 'WHERE', '{', got 'FROM'

Also for FROM NAMED:

SELECT * WHERE {
  SERVICE <http://dbpedia.org/sparql> {
    SELECT *
	FROM NAMED <http://dbpedia.org>
	WHERE {
	  ?s ?p ?o
    }
  }
}
@joachimvh
Copy link
Collaborator

Actually not a valid query. Can't find the immediate reason in the spec, but the grammar defines queries and subqueries differently:

[7] | SelectQuery    | ::= | SelectClause DatasetClause* WhereClause SolutionModifier
[8] | SubSelect      | ::= | SelectClause WhereClause SolutionModifier ValuesClause
...
[13] | DatasetClause | ::= | 'FROM' ( DefaultGraphClause | NamedGraphClause )

It's also not accepted on http://sparql.org/validate/query

@rubensworks
Copy link
Collaborator Author

Well that's silly...
I don't immediately see a reason why this would not be allowed.
If true, then this would be a good thing to be resolved in SPARQL 1.2 as well.

For reference, this was reported here: https://discuss.rdf.community/t/sparql-engine-for-node-js/37/15?u=rubensworks

@cygri
Copy link

cygri commented Apr 18, 2019

FROM and FROM NAMED are not allowed in subqueries. They need to be set on the outermost level of the query.

Now, if the subquery is inside a SERVICE clause, then the outermost SELECT is generated implicitly as part of the service call (as an implicit SELECT * WHERE). And there is no way for the query writer to add a FROM or FROM NAMED to that query.

Sometimes, the same result can be achieved by adding the &default-graph-uri or &named-graph-uri parameters of the SPARQL protocol to the service endpoint. Or by using GRAPH <x> { } inside the service clause to switch to the desired graph. Either should have worked here, I think.

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

No branches or pull requests

3 participants