Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
Jena 4.5.0
-
None
Description
I encountered the following issue while testing the neXtProt database in Jena.
If the query –
select ?id where { values (?id ?v1 ?v2) { ('A' 'B' 'C') } } group by ?id having (count(distinct ?v1) = count(distinct ?v2))
– is submitted, then the empty result is returned. However, the result –
( ?id = "A" )
– should by returned.
On the other hand, the query –
select ?id where { {select ?id (count(distinct ?v1) as ?c1) (count(distinct ?v2) as ?c2) { values (?id ?v1 ?v2) { ('A' 'B' 'C') } } group by ?id} filter (?c1 = ?c2) }
– returns the result as expected.
The following code can be used to reproduce the issue:
import org.apache.jena.query.QueryExecution; import org.apache.jena.query.QueryExecutionFactory; import org.apache.jena.query.ResultSet; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; public class Test { static String query1 = "select ?id where { values (?id ?v1 ?v2) { ('A' 'B' 'C') } } group by ?id having (count(distinct ?v1) = count(distinct ?v2))"; static String query2 = "select ?id where { {select ?id (count(distinct ?v1) as ?c1) (count(distinct ?v2) as ?c2) { values (?id ?v1 ?v2) { ('A' 'B' 'C') } } group by ?id} filter (?c1 = ?c2) }"; public static void main(String[] args) { evaluate("Query1:", query1); evaluate("Query2:", query2); } public static void evaluate(String name, String query) { Model model = ModelFactory.createDefaultModel(); QueryExecution qexec = QueryExecutionFactory.create(query, model); ResultSet results = qexec.execSelect(); System.out.println(name); while(results.hasNext()) System.out.println(results.nextSolution()); } }
Attachments
Issue Links
- links to