Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
Jena 2.13.0
-
None
Description
Queries with Subqueries are not functioning properly when a filter clause exists. This is a regression, as it worked properly in 2.11.2 (I haven't checked 2.12.1).
Example:
data.ttl
<http://r1> a <http://type> . <http://r1> a <http://type2> . <http://r2> a <http://type> . <http://r2> a <http://type2> . <http://r3> a <http://type> . <http://r3> a <http://type2> .
Bind Query
select * where { graph <http://graph1> { { select distinct (?_id as ?id) where { values ?_type { <http://type2> } ?_id a ?_type . ?_id a <http://type> . filter ( ?_id = <http://r1> || ?_id = <http://r2> ) } } ?id a <http://type> . bind (<http://type2> as ?type) . ?id a ?type . } } order by ?id
Bind Algebra
(base <http://example/base/> (order (?id) (graph <http://graph1> (join (extend ((?type <http://type2>)) (join (distinct (project (?id) (extend ((?id ?_id)) (filter (|| (= ?_id <http://r1>) (= ?_id <http://r2>)) (join (table (vars ?_type) (row [?_type <http://type2>]) ) (bgp (triple ?_id <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?_type) (triple ?_id <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://type>) )))))) (bgp (triple ?id <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://type>)))) (bgp (triple ?id <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type))))))
Filter Query
select * where { graph <http://graph1> { { select distinct (?_id as ?id) where { values ?_type { <http://type2> } ?_id a ?_type . ?_id a <http://type> . filter ( ?_id = <http://r1> || ?_id = <http://r2> ) } } ?id a <http://type> . ?id a ?type . filter (?type != <http://type> ) . } } order by ?id
Filter Algebra
(base <http://example/base/> (order (?id) (graph <http://graph1> (filter (!= ?type <http://type>) (join (distinct (project (?id) (extend ((?id ?_id)) (filter (|| (= ?_id <http://r1>) (= ?_id <http://r2>)) (join (table (vars ?_type) (row [?_type <http://type2>]) ) (bgp (triple ?_id <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?_type) (triple ?_id <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://type>) )))))) (bgp (triple ?id <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://type>) (triple ?id <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type) ))))))
For both queries, the results should look like:
-------------------------------- | id | type | ================================ | <http://r1> | <http://type2> | | <http://r2> | <http://type2> | --------------------------------
However, only the Bind query actually works correctly. The Filter query returns no rows.