1

I am trying to run a sparql query on a local rdf dataset. The dataset is parsed successfully. The following query containing the group by clause gives the exception 'Cannot eval thing: None (<class 'NoneType'>)'

select (COUNT(?person)  as ?cnt)  ?name where {
  ?person <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://swrc.ontoware.org/ontology#Person> . 
  
  ?person <http://swrc.ontoware.org/ontology#affiliation> ?aff .

  #  ?aff a <http://swrc.ontoware.org/ontology#affiliation>.
  ?aff <http://swrc.ontoware.org/ontology#name> ?name .
} group by(?name)

If I remove the brackets from the variable name in the group by clause like below the query works fine without any errors.

select (COUNT(?person)  as ?cnt)  ?name where {
  ?person <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://swrc.ontoware.org/ontology#Person> . 
  
  ?person <http://swrc.ontoware.org/ontology#affiliation> ?aff .

  #  ?aff a <http://swrc.ontoware.org/ontology#affiliation>.
  ?aff <http://swrc.ontoware.org/ontology#name> ?name .
} group by ?name

I cannot see why the brackets would cause an error or how I should use rdflib to work with that format too. Any help would be really appreciated!

Aniqa295
  • 21
  • 1
  • 2
    This sounds like a bug in rdflib - the fact that brackets are allowed around simple variables in a `group by` clause is not immediately obvious when looking at the grammar (https://www.w3.org/TR/sparql11-query/#rGroupClause). The developers may simply have overlooked this. As for how to get it to work: rdflib is open-source, so log a bug report, and perhaps even try and submit a fix? – Jeen Broekstra Feb 13 '21 at 00:15
  • For online testing with the grammar: http://www.sparql.org/query-validator.html (it's using the grammar file used to generate the HTML in the spec). – AndyS Feb 13 '21 at 20:30

0 Answers0