[ 
https://issues.apache.org/jira/browse/JENA-1148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15169051#comment-15169051
 ] 

Eetu Mäkelä commented on JENA-1148:
-----------------------------------

If the data included {{<urn:b1> <urn:b2> <urn:x1>}}, should I not get 
{{?s=<urn:b1>,?p=<urn:b2>,?o=<urn:x1>,?b=true}} out instead of just 
{{?s=<urn:b1>,?p=<urn:b2>,?o=<urn:x1>}}?

In any case, the BIND is just a placeholder, it could be anything. Here's a 
different practical example:
{code}
SELECT * {
 ?s a edm:ProvidedCHO .
 ?s ?p ?o .
 OPTIONAL {
   FILTER(?p=dct:spatial)
   ?o wgs84:lat ?lat .
   ?o wgs84:long ?long .
 }
}
{code}
The idea being that in a single query, you get all properties for all cultural 
heritage objects, but also if that property happens to be a relation between 
the object and a place, then you also grab that place's coordinates. However, 
currently, the above will never return any coordinates, because the optimizer 
thinks {{?p}} can never be bound inside the block.

(the situation where I _actually_ encountered this included a SERVICE call 
which needed to run only on certain predicates to get further info from a 
separate service on the objects of those predicates)

> TransformFilterEquality incorrectly eliminates some optionals
> -------------------------------------------------------------
>
>                 Key: JENA-1148
>                 URL: https://issues.apache.org/jira/browse/JENA-1148
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: ARQ
>            Reporter: Eetu Mäkelä
>              Labels: Optimization, sparql
>
> For a query of the form:
> {code}
> SELECT * {
>   ?s ?p ?o
>   OPTIONAL {
>     FILTER(?o=<urn:x1>)
>     BIND(true AS ?b)
>   }
> }
> {code}
> ARQ optimization incorrectly eliminates the whole OPTIONAL when the variable 
> filtered on does not appear elsewhere inside the OPTIONAL block . This is 
> because of the special case check called on [line 120 of 
> TransformFilterEquality.java|https://git-wip-us.apache.org/repos/asf?p=jena.git;a=blob;f=jena-arq/src/main/java/org/apache/jena/sparql/algebra/optimize/TransformFilterEquality.java;h=38ba84019ba3b446afd8106128c517913a7ef73e;hb=6908fb7b7a500a70edb314b4830a18ed02a6b0f8#l120],
>  which sees that ?o is not used inside the block of the filter and thus (in 
> this case incorrectly) deduces that it could never be <urn:x1>.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to