corese icon indicating copy to clipboard operation
corese copied to clipboard

Problem with mappings of select (count(...) ) requests ?

Open ErwanDemairy opened this issue 9 years ago • 1 comments

Hello, It seems when making a "SELECT (count(?z) as ?count) WHERE { ?y humans:hasFriend ?z }" request, the mapping returned contains "ghost" values of ?y ?z even if there are not asked for by the select. If I run the following program: public class MappingsProblem { public static void main(String[] args) throws EngineException{ Graph graph = Graph.create(); Load ld = Load.create(graph); ld.load("human_2007_04_17.rdf"); QueryProcess exec = QueryProcess.create(graph); String query = "PREFIX humans: <http://www.inria.fr/2007/04/17/humans.rdfs#>\n SELECT (count(?z) as ?count) WHERE { ?y humans:hasFriend ?z }"; Mappings map = exec.query(query); ResultFormat f1 = ResultFormat.create(map); System.out.println(map.get(0).toString()); System.out.println(f1); } } I obtain the following output: ` ?y = http://www.inria.fr/2007/04/17/humans.rdfs-instances#Eve ?z = http://www.inria.fr/2007/04/17/humans.rdfs-instances#Alice ?count = 6

6 ` In my case, this breaks a test since the content of ?y and ?z are undetermistic, and the producer I work on does not return the same values as the corese normal producer. So the method TestW3C11KGraph::validate() see the two results as different although the ?count is the same (and should be the only one used in comparison in my opinion). So my question: is this an expected behaviour, or is this a bug? Best regards, Erwan

ErwanDemairy avatar Dec 09 '16 14:12 ErwanDemairy

Hello,

There are two solutions:

  1. use (count(*) as ?c) instead of (count(?z) as ?c)

  2. use map.getSelect() to iterate on select variables of the query to compare result Mappings.

Regards,

Olivier

ocorby avatar Dec 12 '16 08:12 ocorby