-
Notifications
You must be signed in to change notification settings - Fork 587
Open
Description
rdflib.Graph.query does not enforce Aggregate Projection Restrictions.
E.g. the following
query = """
select (count(*) as ?cnt) ?parent ?child ?name
where {
values (?parent ?child ?name) {
('x' 'c' 'foo')
('y' 'd' UNDEF)
('y' 'e' UNDEF)
('z' UNDEF UNDEF)
}
}
"""
graph = Graph()
result = graph.query(query)
result.bindingsis invalid SPARQL according to Aggregate Projection Restrictions:
In a query level which uses aggregates, only expressions consisting of aggregates and constants may be projected, with one exception. When GROUP BY is given with one or more simple expressions consisting of just a variable, those variables may be projected from the level.
Yet the above code results in
[
{
rdflib.term.Variable("parent"): rdflib.term.Literal("x"),
rdflib.term.Variable("child"): rdflib.term.Literal("c"),
rdflib.term.Variable("name"): rdflib.term.Literal("foo"),
rdflib.term.Variable("cnt"): rdflib.term.Literal(
"4", datatype=rdflib.term.URIRef("http://www.w3.org/2001/XMLSchema#integer")
),
}
]Blazegraph and GraphDB reject the query with Malformed Query exceptions.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels